Migrate javaagent-* to kotlin dsl
DELETE
javaagent-api/build.gradle
-plugins {
- id("otel.java-conventions")
- id("otel.jacoco-conventions")
- id("otel.publish-conventions")
-}
-
-group = 'io.opentelemetry.javaagent'
-
-
-dependencies {
- api "io.opentelemetry:opentelemetry-api"
- compileOnly "io.opentelemetry:opentelemetry-sdk"
- implementation "org.slf4j:slf4j-api"
- implementation project(':instrumentation-api')
- compileOnly "com.google.auto.value:auto-value-annotations"
- annotationProcessor "com.google.auto.value:auto-value"
-
- testImplementation project(':testing-common')
- testImplementation "org.mockito:mockito-core"
- testImplementation "org.mockito:mockito-junit-jupiter"
- testImplementation "org.assertj:assertj-core"
-}

ADD
javaagent-api/build.gradle.kts
+plugins {
+ id("otel.java-conventions")
+ id("otel.jacoco-conventions")
+ id("otel.publish-conventions")
+}
+
+group = "io.opentelemetry.javaagent"
+
+dependencies {
+ api("io.opentelemetry:opentelemetry-api")
+ compileOnly("io.opentelemetry:opentelemetry-sdk")
+
+ implementation(project(":instrumentation-api"))
+ implementation("org.slf4j:slf4j-api")
+
+ compileOnly("com.google.auto.value:auto-value-annotations")
+ annotationProcessor("com.google.auto.value:auto-value")
+
+ testImplementation(project(":testing-common"))
+ testImplementation("org.mockito:mockito-core")
+ testImplementation("org.mockito:mockito-junit-jupiter")
+ testImplementation("org.assertj:assertj-core")
+}

RENAME
javaagent-bootstrap-tests/build.gradle
javaagent-bootstrap-tests/build.gradle.kts
@@ -5,8 +5,8 @@ plugins {
dependencies {
// For testing javaagent-bootstrap's Caffeine patch, we need to compile against our cache API
// but make sure to run against javaagent-bootstrap
- testCompileOnly project(':instrumentation-api-caching')
- testRuntimeOnly project(":javaagent-bootstrap")
+ testCompileOnly(project(":instrumentation-api-caching"))
+ testRuntimeOnly(project(":javaagent-bootstrap"))
- testImplementation "org.assertj:assertj-core"
+ testImplementation("org.assertj:assertj-core")
}

DELETE
javaagent-bootstrap/build.gradle
-plugins {
- id("otel.java-conventions")
- id("otel.publish-conventions")
-}
-
-group = 'io.opentelemetry.javaagent'
-
-// patch inner class from Caffeine to avoid ForkJoinTask from being loaded too early
-sourceSets {
- patch {
- java {}
- }
-}
-jar {
- from(sourceSets.patch.output) {
- include 'io/opentelemetry/instrumentation/api/internal/shaded/caffeine/cache/BoundedLocalCache$PerformCleanupTask.class'
- }
-}
-
-configurations {
- // classpath used by the instrumentation muzzle plugin
- instrumentationMuzzle {
- canBeConsumed = true
- canBeResolved = false
- extendsFrom implementation
- }
-}
-
-dependencies {
- api "io.opentelemetry:opentelemetry-api"
- api "io.opentelemetry:opentelemetry-api-metrics"
- compileOnly "io.opentelemetry:opentelemetry-sdk"
- implementation "org.slf4j:slf4j-api"
- implementation "org.slf4j:slf4j-simple"
- // ^ Generally a bad idea for libraries, but we're shadowing.
-
- implementation project(':javaagent-api')
- implementation project(':instrumentation-api')
-
- testImplementation project(':testing-common')
- testImplementation "org.mockito:mockito-core"
- testImplementation "org.assertj:assertj-core"
-}

ADD
javaagent-bootstrap/build.gradle.kts
+plugins {
+ id("otel.java-conventions")
+ id("otel.publish-conventions")
+}
+
+group = "io.opentelemetry.javaagent"
+
+// patch inner class from Caffeine to avoid ForkJoinTask from being loaded too early
+val patch = sourceSets.create("patch")
+patch.java {}
+
+tasks {
+ named<Jar>("jar") {
+ from(patch.output) {
+ include("io/opentelemetry/instrumentation/api/internal/shaded/caffeine/cache/BoundedLocalCache\$PerformCleanupTask.class")
+ }
+ }
+}
+
+val instrumentationMuzzle by configurations.creating {
+ isCanBeConsumed = true
+ isCanBeResolved = false
+ extendsFrom(configurations.implementation.get())
+}
+
+dependencies {
+ api("io.opentelemetry:opentelemetry-api")
+ api("io.opentelemetry:opentelemetry-api-metrics")
+
+ compileOnly("io.opentelemetry:opentelemetry-sdk")
+
+ implementation(project(":instrumentation-api"))
+ implementation(project(":javaagent-api"))
+
+ implementation("org.slf4j:slf4j-api")
+ implementation("org.slf4j:slf4j-simple")
+ // ^ Generally a bad idea for libraries, but we're shadowing.
+
+ testImplementation(project(":testing-common"))
+ testImplementation("org.mockito:mockito-core")
+ testImplementation("org.assertj:assertj-core")
+}

DELETE
javaagent-exporters/build.gradle
-// Project to collect and shade exporter dependencies included in the agent's full distribution.
-
-plugins {
- id("otel.java-conventions")
- id("otel.shadow-conventions")
-}
-
-dependencies {
- implementation "io.opentelemetry:opentelemetry-exporter-jaeger"
- implementation "io.opentelemetry:opentelemetry-exporter-otlp"
- implementation "io.opentelemetry:opentelemetry-exporter-otlp-metrics"
-
- implementation "io.opentelemetry:opentelemetry-exporter-prometheus"
- implementation "io.prometheus:simpleclient"
- implementation "io.prometheus:simpleclient_httpserver"
-
- implementation "io.opentelemetry:opentelemetry-exporter-zipkin"
-
- // TODO(anuraaga): Move version to dependency management
- implementation "io.grpc:grpc-netty-shaded:1.38.0"
-}
-
-configurations {
- // exclude bootstrap dependencies from shadowJar
- implementation.exclude group: 'io.opentelemetry', module: 'opentelemetry-api'
- implementation.exclude group: 'io.opentelemetry', module: 'opentelemetry-api-metrics'
- implementation.exclude group: 'io.opentelemetry', module: 'opentelemetry-semconv'
-}

ADD
javaagent-exporters/build.gradle.kts
+// Project to collect and shade exporter dependencies included in the agent's full distribution.
+
+plugins {
+ id("otel.java-conventions")
+ id("otel.shadow-conventions")
+}
+
+dependencies {
+ implementation("io.opentelemetry:opentelemetry-exporter-jaeger")
+ implementation("io.opentelemetry:opentelemetry-exporter-otlp")
+ implementation("io.opentelemetry:opentelemetry-exporter-otlp-metrics")
+
+ implementation("io.opentelemetry:opentelemetry-exporter-prometheus")
+ implementation("io.prometheus:simpleclient")
+ implementation("io.prometheus:simpleclient_httpserver")
+
+ implementation("io.opentelemetry:opentelemetry-exporter-zipkin")
+
+ // TODO(anuraaga): Move version to dependency management
+ implementation("io.grpc:grpc-netty-shaded:1.38.0")
+}
+
+configurations {
+ implementation {
+ exclude("io.opentelemetry", "opentelemetry-api")
+ exclude("io.opentelemetry", "opentelemetry-api-metrics")
+ exclude("io.opentelemetry", "opentelemetry-semconv")
+ }
+}

DELETE
javaagent-extension-api/build.gradle
-plugins {
- id("otel.java-conventions")
- id("otel.publish-conventions")
-}
-
-group = 'io.opentelemetry.javaagent'
-
-configurations {
- // classpath used by the instrumentation muzzle plugin
- instrumentationMuzzle {
- canBeConsumed = true
- canBeResolved = false
- extendsFrom api, implementation
- }
-}
-
-dependencies {
- api "io.opentelemetry:opentelemetry-sdk"
- // metrics are unstable, do not expose as api
- implementation "io.opentelemetry:opentelemetry-sdk-metrics"
- api "net.bytebuddy:byte-buddy"
- api "org.slf4j:slf4j-api"
-
- implementation project(":instrumentation-api")
- implementation project(":javaagent-api")
- // TODO: ideally this module should not depend on bootstrap, bootstrap should be an internal component
- implementation project(":javaagent-bootstrap")
-
- instrumentationMuzzle sourceSets.main.output
-}
\ No newline at end of file

ADD
javaagent-extension-api/build.gradle.kts
+plugins {
+ id("otel.java-conventions")
+ id("otel.publish-conventions")
+}
+
+group = "io.opentelemetry.javaagent"
+
+val instrumentationMuzzle by configurations.creating {
+ isCanBeConsumed = true
+ isCanBeResolved = false
+ // TODO(anuraaga): Should be compileClasspath?
+ extendsFrom(configurations.api.get())
+ extendsFrom(configurations.implementation.get())
+}
+
+dependencies {
+ api("io.opentelemetry:opentelemetry-sdk")
+
+ api("net.bytebuddy:byte-buddy")
+ api("org.slf4j:slf4j-api")
+
+ implementation(project(":instrumentation-api"))
+ implementation(project(":javaagent-api"))
+ // TODO: ideally this module should not depend on bootstrap, bootstrap should be an internal component
+ implementation(project(":javaagent-bootstrap"))
+
+ // metrics are unstable, do not expose as api
+ implementation("io.opentelemetry:opentelemetry-sdk-metrics")
+
+ instrumentationMuzzle(sourceSets.main.get().output)
+}

DELETE
javaagent-tooling/build.gradle
-plugins {
- id("otel.java-conventions")
- id("otel.publish-conventions")
-}
-
-group = 'io.opentelemetry.javaagent'
-
-configurations {
- // classpath used by the instrumentation muzzle plugin
- instrumentationMuzzle {
- canBeConsumed = true
- canBeResolved = false
- extendsFrom implementation
- }
-}
-
-dependencies {
- // Only used during compilation by bytebuddy plugin
- compileOnly "com.google.guava:guava"
-
- implementation project(':javaagent-bootstrap')
- implementation project(':javaagent-extension-api')
- implementation project(':javaagent-api')
- implementation project(':instrumentation-api')
-
- implementation "io.opentelemetry:opentelemetry-api"
- implementation "io.opentelemetry:opentelemetry-api-metrics"
- implementation "io.opentelemetry:opentelemetry-sdk"
- implementation "io.opentelemetry:opentelemetry-sdk-extension-autoconfigure"
- implementation "io.opentelemetry:opentelemetry-sdk-metrics"
- implementation("io.opentelemetry:opentelemetry-extension-kotlin")
- implementation "io.opentelemetry:opentelemetry-extension-aws"
- implementation "io.opentelemetry:opentelemetry-extension-trace-propagators"
- implementation "io.opentelemetry:opentelemetry-sdk-extension-resources"
-
- // Only the logging exporter is included in our slim distribution so we include it here.
- // Other exporters are in javaagent-exporters
- implementation "io.opentelemetry:opentelemetry-exporter-logging"
-
- api "net.bytebuddy:byte-buddy"
- annotationProcessor "com.google.auto.service:auto-service"
- compileOnly "com.google.auto.service:auto-service"
- implementation "org.slf4j:slf4j-api"
-
- testImplementation project(':testing-common')
- testImplementation "com.google.guava:guava"
- testImplementation "org.assertj:assertj-core"
- testImplementation "org.mockito:mockito-core"
- testImplementation "org.mockito:mockito-junit-jupiter"
-
- instrumentationMuzzle sourceSets.main.output
-}
-
-// Here we only include autoconfigure but don't include OTLP exporters to ensure they are only in
-// the full distribution. We need to override the default exporter setting of OTLP as a result.
-tasks.withType(Test).configureEach {
- environment "OTEL_TRACES_EXPORTER", "none"
- environment "OTEL_METRICS_EXPORTER", "none"
-}

ADD
javaagent-tooling/build.gradle.kts
+plugins {
+ id("otel.java-conventions")
+ id("otel.publish-conventions")
+}
+
+group = "io.opentelemetry.javaagent"
+
+val instrumentationMuzzle by configurations.creating {
+ isCanBeConsumed = true
+ isCanBeResolved = false
+ extendsFrom(configurations.implementation.get())
+}
+
+dependencies {
+ // Only used during compilation by bytebuddy plugin
+ compileOnly("com.google.guava:guava")
+
+ implementation(project(":javaagent-bootstrap"))
+ implementation(project(":javaagent-extension-api"))
+ implementation(project(":javaagent-api"))
+ implementation(project(":instrumentation-api"))
+
+ implementation("io.opentelemetry:opentelemetry-api")
+ implementation("io.opentelemetry:opentelemetry-api-metrics")
+ implementation("io.opentelemetry:opentelemetry-sdk")
+ implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
+ implementation("io.opentelemetry:opentelemetry-sdk-metrics")
+ implementation("io.opentelemetry:opentelemetry-extension-kotlin")
+ implementation("io.opentelemetry:opentelemetry-extension-aws")
+ implementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
+ implementation("io.opentelemetry:opentelemetry-sdk-extension-resources")
+
+ // Only the logging exporter is included in our slim distribution so we include it here.
+ // Other exporters are in javaagent-exporters
+ implementation("io.opentelemetry:opentelemetry-exporter-logging")
+
+ api("net.bytebuddy:byte-buddy")
+ implementation("org.slf4j:slf4j-api")
+
+ annotationProcessor("com.google.auto.service:auto-service")
+ compileOnly("com.google.auto.service:auto-service")
+
+ testImplementation(project(":testing-common"))
+ testImplementation("com.google.guava:guava")
+ testImplementation("org.assertj:assertj-core")
+ testImplementation("org.mockito:mockito-core")
+ testImplementation("org.mockito:mockito-junit-jupiter")
+
+ instrumentationMuzzle(sourceSets.main.get().output)
+}
+
+// Here we only include autoconfigure but don"t include OTLP exporters to ensure they are only in
+// the full distribution. We need to override the default exporter setting of OTLP as a result.
+tasks {
+ withType<Test>().configureEach {
+ environment("OTEL_TRACES_EXPORTER", "none")
+ environment("OTEL_METRICS_EXPORTER", "none")
+ }
+}

Migrate javaagent-* to kotlin dsl (#3434)