Skip to content

Commit

Permalink
Fix javaagent publishing (#3929) (#3937)
Browse files Browse the repository at this point in the history
* Fix javaagent publishing

* Take manifest attributes from the jar task too

Co-authored-by: Mateusz Rzeszutek <[email protected]>
  • Loading branch information
trask and Mateusz Rzeszutek authored Aug 24, 2021
1 parent b90ba64 commit a934914
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
4 changes: 2 additions & 2 deletions benchmark-e2e/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ dependencies {

tasks {
test {
dependsOn(":javaagent:shadowJar")
dependsOn(":javaagent:fullJavaagentJar")
maxParallelForks = 2

doFirst {
jvmArgs("-Dio.opentelemetry.smoketest.agent.shadowJar.path=${project(":javaagent").tasks.getByName<ShadowJar>("shadowJar").archivePath}")
jvmArgs("-Dio.opentelemetry.smoketest.agent.shadowJar.path=${project(":javaagent").tasks.getByName<ShadowJar>("fullJavaagentJar").archivePath}")
}
}
}
2 changes: 1 addition & 1 deletion benchmark-overhead-jmh/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tasks {
val jmhStartFlightRecording = gradle.startParameter.projectProperties.get("jmh.startFlightRecording")

named<JMHTask>("jmh") {
val shadowTask = project(":javaagent").tasks.named<ShadowJar>("shadowJar").get()
val shadowTask = project(":javaagent").tasks.named<ShadowJar>("fullJavaagentJar").get()
inputs.files(layout.files(shadowTask))

// note: without an exporter, toSpanData() won't even be called
Expand Down
2 changes: 1 addition & 1 deletion benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ tasks {
}

named("jmh") {
dependsOn(":javaagent:shadowJar")
dependsOn(":javaagent:fullJavaagentJar")
}
}

Expand Down
22 changes: 9 additions & 13 deletions javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ tasks {
}
}

// lightShadow is the default classifier we publish so disable the default jar.
jar {
enabled = false
}

val relocateJavaagentLibs by registering(ShadowJar::class) {
configurations = listOf(javaagentLibs)

Expand All @@ -128,7 +123,7 @@ tasks {
}

//Includes instrumentations, but not exporters
val lightShadow by registering(ShadowJar::class) {
val shadowJar by existing(ShadowJar::class) {
configurations = listOf(bootstrapLibs)

dependsOn(relocateJavaagentLibs)
Expand All @@ -137,6 +132,7 @@ tasks {
archiveClassifier.set("")

manifest {
attributes(jar.get().manifest.attributes)
attributes(
"Main-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Agent-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
Expand All @@ -148,7 +144,7 @@ tasks {
}

//Includes everything needed for OOTB experience
val shadowJar by existing(ShadowJar::class) {
val fullJavaagentJar by registering(ShadowJar::class) {
configurations = listOf(bootstrapLibs)

dependsOn(relocateJavaagentLibs, relocateExporterLibs)
Expand All @@ -160,23 +156,23 @@ tasks {
archiveClassifier.set("all")

manifest {
attributes(lightShadow.get().manifest.attributes)
attributes(shadowJar.get().manifest.attributes)
}
}

assemble {
dependsOn(lightShadow, shadowJar)
dependsOn(shadowJar, fullJavaagentJar)
}

withType<Test>().configureEach {
dependsOn(shadowJar)
inputs.file(shadowJar.get().archiveFile)
dependsOn(fullJavaagentJar)
inputs.file(fullJavaagentJar.get().archiveFile)

jvmArgs("-Dotel.javaagent.debug=true")

doFirst {
// Defining here to allow jacoco to be first on the command line.
jvmArgs("-javaagent:${shadowJar.get().archiveFile.get().asFile}")
jvmArgs("-javaagent:${fullJavaagentJar.get().archiveFile.get().asFile}")
}

testLogging {
Expand All @@ -195,7 +191,7 @@ tasks {
publishing {
publications {
named<MavenPublication>("maven") {
artifact(lightShadow)
artifact(fullJavaagentJar)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions smoke-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {

tasks {
test {
inputs.files(project(":javaagent").tasks.getByName("shadowJar").outputs.files)
inputs.files(project(":javaagent").tasks.getByName("fullJavaagentJar").outputs.files)
maxParallelForks = 2

testLogging.showStandardStreams = true
Expand Down Expand Up @@ -79,7 +79,7 @@ tasks {
}
}

val shadowTask = project(":javaagent").tasks.named<ShadowJar>("shadowJar").get()
val shadowTask = project(":javaagent").tasks.named<ShadowJar>("fullJavaagentJar").get()
inputs.files(layout.files(shadowTask))

doFirst {
Expand Down

0 comments on commit a934914

Please sign in to comment.