From bf46ff1074c31265d1f636ad2e9f23bffe3164ef Mon Sep 17 00:00:00 2001 From: Christian Stein Date: Sat, 7 Sep 2019 08:38:08 +0200 Subject: [PATCH] Correct file type of module descriptors included in JAR files Prior to this commit, all JAR files generated for a published module included their compiled module descriptor within the root directory of the artifact. This commit a) includes the compiled module descriptor only in JAR files that have no classifier specified and b) stores the source of each module descriptor within the matching `*-source.jar` file. Fixes #2003 --- .../main/kotlin/java-library-conventions.gradle.kts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/java-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/java-library-conventions.gradle.kts index a35bdd8bf06c..2d6047511365 100644 --- a/buildSrc/src/main/kotlin/java-library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/java-library-conventions.gradle.kts @@ -80,6 +80,9 @@ if (project in mavenizedProjects) { dependsOn(tasks.classes) archiveClassifier.set("sources") from(sourceSets.main.get().allSource) + from("${project.projectDir}/src/module/$javaModuleName") { + include("module-info.java") + } duplicatesStrategy = DuplicatesStrategy.EXCLUDE } @@ -93,8 +96,11 @@ if (project in mavenizedProjects) { include("LICENSE.md", "LICENSE-notice.md") into("META-INF") } - from("$buildDir/classes/java/module/$javaModuleName") { - include("module-info.class") + val suffix = archiveClassifier.getOrElse("") + if (suffix.isBlank() || suffix == "all") { // "all" is used by shadow plugin + from("$buildDir/classes/java/module/$javaModuleName") { + include("module-info.class") + } } }