From de2f8b4aee64f05c4790f7f369278f4cd0b9fb5d Mon Sep 17 00:00:00 2001 From: Andreas Schaefer Date: Tue, 21 Feb 2023 09:20:10 -0800 Subject: [PATCH] Ensured that the MANIFEST.MF files is the first entry in the JAR file as it is required for java.util.jar.JarFile to obtain the manfiest entry which is essential for Sling to work. --- build.gradle | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 0e363f1128..d20edfdc16 100644 --- a/build.gradle +++ b/build.gradle @@ -160,20 +160,27 @@ Import-Package: !com.google.*,!org.checkerframework.*,!javax.annotation.*,!graph } -task removeNotNeededGuava(type: Zip) { +task extractWithoutGuava(type: Copy) { from({ zipTree({ "build/libs/graphql-java-${project.version}.jar" }) }) { exclude('/com/**') } + into layout.buildDirectory.dir("extract") +} + +task buildNewJar(type: Jar) { + from layout.buildDirectory.dir("extract") archiveFileName = "graphql-java-tmp.jar" destinationDirectory = file("${project.buildDir}/libs") + manifest { + from file("build/extract/META-INF/MANIFEST.MF") + } doLast { delete("build/libs/graphql-java-${project.version}.jar") file("build/libs/graphql-java-tmp.jar").renameTo(file("build/libs/graphql-java-${project.version}.jar")) } } - -shadowJar.finalizedBy removeNotNeededGuava +shadowJar.finalizedBy extractWithoutGuava, buildNewJar task testng(type: Test) {