Added Automatic-Module-Name header to MANIFEST.MF in instrumentation libraries (#9140)
Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
This commit is contained in:
parent
0de1dcff45
commit
57e6be4e32
|
@ -194,6 +194,41 @@ testing {
|
|||
}
|
||||
}
|
||||
|
||||
var path = project.path
|
||||
if (path.startsWith(":instrumentation:")) {
|
||||
// remove segments that are a prefix of the next segment
|
||||
// for example :instrumentation:log4j:log4j-context-data:log4j-context-data-2.17 is transformed to log4j-context-data-2.17
|
||||
var tmpPath = path
|
||||
val suffix = tmpPath.substringAfterLast(':')
|
||||
var prefix = ":instrumentation:"
|
||||
if (suffix == "library") {
|
||||
// strip ":library" suffix
|
||||
tmpPath = tmpPath.substringBeforeLast(':')
|
||||
} else if (suffix == "library-autoconfigure") {
|
||||
// replace ":library-autoconfigure" with "-autoconfigure"
|
||||
tmpPath = tmpPath.substringBeforeLast(':') + "-autoconfigure"
|
||||
} else if (suffix == "javaagent") {
|
||||
// strip ":javaagent" suffix and add it to prefix
|
||||
prefix += "javaagent:"
|
||||
tmpPath = tmpPath.substringBeforeLast(':')
|
||||
}
|
||||
val segments = tmpPath.substring(":instrumentation:".length).split(':')
|
||||
var newPath = ""
|
||||
var done = false
|
||||
for (s in segments) {
|
||||
if (!done && (newPath.isEmpty() || s.startsWith(newPath))) {
|
||||
newPath = s
|
||||
} else {
|
||||
newPath += ":$s"
|
||||
done = true
|
||||
}
|
||||
}
|
||||
if (newPath.isNotEmpty()) {
|
||||
path = prefix + newPath
|
||||
}
|
||||
}
|
||||
var javaModuleName = "io.opentelemetry" + path.replace(".", "_").replace("-", "_").replace(":", ".")
|
||||
|
||||
tasks {
|
||||
named<Jar>("jar") {
|
||||
// By default Gradle Jar task can put multiple files with the same name
|
||||
|
@ -210,7 +245,8 @@ tasks {
|
|||
"Implementation-Title" to project.name,
|
||||
"Implementation-Version" to project.version,
|
||||
"Implementation-Vendor" to "OpenTelemetry",
|
||||
"Implementation-URL" to "https://github.com/open-telemetry/opentelemetry-java-instrumentation"
|
||||
"Implementation-URL" to "https://github.com/open-telemetry/opentelemetry-java-instrumentation",
|
||||
"Automatic-Module-Name" to javaModuleName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue