Avoid having two tasks producing the same file
MODIFY
javaagent/build.gradle.kts
javaagent/build.gradle.kts
@@ -145,12 +145,7 @@ tasks {
val shadowJar by existing(ShadowJar::class) {
configurations = listOf(bootstrapLibs)
- // without an explicit dependency on jar here, :javaagent:test fails on CI because :javaagent:jar
- // runs after :javaagent:shadowJar and loses (at least) the manifest entries
- //
- // (also, note that we cannot disable the jar task completely, because it is necessary to produce
- // javadoc and sources artifacts which maven central requires)
- dependsOn(jar, relocateJavaagentLibs, relocateExporterLibs)
+ dependsOn(relocateJavaagentLibs, relocateExporterLibs)
isolateClasses(relocateJavaagentLibs.get().outputs.files)
isolateClasses(relocateExporterLibs.get().outputs.files)
@@ -186,6 +181,11 @@ tasks {
}
}
+ jar {
+ // Empty jar that cannot be used for anything and isn't published.
+ archiveClassifier.set("dontuse")
+ }
+
val baseJar by configurations.creating {
isCanBeConsumed = true
isCanBeResolved = false
@@ -218,6 +218,25 @@ tasks {
named("generateLicenseReport").configure {
dependsOn(cleanLicenses)
}
+
+ // Because we reconfigure publishing to only include the shadow jar, the Gradle metadata is not correct.
+ // Since we are fully bundled and have no dependencies, Gradle metadata wouldn't provide any advantage over
+ // the POM anyways so in practice we shouldn't be losing anything.
+ withType<GenerateModuleMetadata>().configureEach {
+ enabled = false
+ }
+}
+
+// Don't publish non-shadowed jar (shadowJar is in shadowRuntimeElements)
+with(components["java"] as AdhocComponentWithVariants) {
+ configurations.forEach {
+ withVariantsFromConfiguration(configurations["apiElements"]) {
+ skip()
+ }
+ withVariantsFromConfiguration(configurations["runtimeElements"]) {
+ skip()
+ }
+ }
}
licenseReport {

Avoid having two tasks producing the same file (#5334)