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

This commit is contained in:
Anuraag Agrawal 2020-09-01 20:04:32 +09:00 committed by GitHub
parent ecef123305
commit 4c3e99fec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 3 deletions

View File

@ -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}"
}

View File

@ -1,9 +1,11 @@
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 {

View File

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

View File

@ -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

View File

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