Set instrumentation groups to unique values when using auto/library/testing pattern.
MODIFY
gradle/instrumentation-common.gradle
gradle/instrumentation-common.gradle
@@ -74,3 +74,12 @@ if (testLatestDeps) {
}
}
}
+
+if (['auto', 'library', 'testing'].contains(projectDir.name)) {
+ // We don't use this group anywhere in our config, but we need to make sure it is unique per
+ // instrumentation so Gradle doesn't merge projects with same name due to a bug in Gradle.
+ // https://github.com/gradle/gradle/issues/847
+ // In publish.gradle, we set the maven group, which is what matters, to the correct
+ // value.
+ group = "io.opentelemetry.${projectDir.parentFile.name}"
+}

MODIFY
gradle/instrumentation-library.gradle
gradle/instrumentation-library.gradle
-group = 'io.opentelemetry.instrumentation'
-
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/publish.gradle"
apply from: "$rootDir/gradle/instrumentation-common.gradle"
+ext {
+ mavenGroupId = 'io.opentelemetry.instrumentation'
+}
+
archivesBaseName = projectDir.parentFile.name
dependencies {

MODIFY
gradle/instrumentation.gradle
gradle/instrumentation.gradle
@@ -6,6 +6,7 @@ apply plugin: 'muzzle'
ext {
packageInAgentBundle = true
+ mavenGroupId = 'io.opentelemetry.instrumentation.auto'
}
byteBuddy {

MODIFY
gradle/java.gradle
gradle/java.gradle
@@ -10,7 +10,7 @@ apply from: "$rootDir/gradle/codenarc.gradle"
apply from: "$rootDir/gradle/spotbugs.gradle"
afterEvaluate {
- if (group == 'io.opentelemetry.instrumentation.auto') {
+ if (group == 'io.opentelemetry.instrumentation.auto' || findProperty('mavenGroupId') == 'io.opentelemetry.instrumentation.auto') {
archivesBaseName = 'opentelemetry-auto-' + archivesBaseName
} else {
archivesBaseName = 'opentelemetry-' + archivesBaseName

MODIFY
gradle/publish.gradle
gradle/publish.gradle
@@ -20,6 +20,10 @@ publishing {
}
afterEvaluate {
+ def mavenGroupId = project.findProperty('mavenGroupId')
+ if (mavenGroupId) {
+ groupId = mavenGroupId
+ }
artifactId = artifactPrefix(project, archivesBaseName) + archivesBaseName
}

Set instrumentation groups to unique values when using auto/library/testing pattern. (#1145)