opentelemetry-java-instrume.../testing/agent-for-testing/agent-for-testing.gradle

79 lines
1.9 KiB
Groovy

plugins {
id "otel.shadow-conventions"
}
description = 'OpenTelemetry Javaagent for testing'
group = 'io.opentelemetry.javaagent'
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/publish.gradle"
jar {
manifest {
attributes(
"Main-Class": "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Agent-Class": "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Premain-Class": "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true,
)
}
}
CopySpec isolateSpec(Collection<Jar> shadowJarTasks) {
return copySpec {
from({ shadowJarTasks.collect { zipTree(it.archiveFile) } }) {
// important to keep prefix 'inst' short, as it is prefixed to lots of strings in runtime mem
into 'inst'
rename '(^.*)\\.class$', '$1.classdata'
// Rename LICENSE file since it clashes with license dir on non-case sensitive FSs (i.e. Mac)
rename '^LICENSE$', 'LICENSE.renamed'
}
}
}
configurations {
shadowInclude {
canBeResolved = true
canBeConsumed = false
}
}
evaluationDependsOn(":testing:agent-exporter")
shadowJar {
configurations = [project.configurations.shadowInclude]
archiveClassifier.set("")
dependsOn ':testing:agent-exporter:shadowJar'
with isolateSpec([project(':testing:agent-exporter').tasks.shadowJar])
manifest {
inheritFrom project.tasks.jar.manifest
}
}
jar {
enabled = false
}
dependencies {
// Dependencies to include without obfuscation.
shadowInclude project(':javaagent-bootstrap')
testImplementation project(':testing-common')
testImplementation "io.opentelemetry:opentelemetry-api"
}
afterEvaluate {
tasks.withType(Test).configureEach {
inputs.file(shadowJar.archiveFile)
jvmArgs "-Dotel.javaagent.debug=true"
jvmArgs "-javaagent:${shadowJar.archiveFile.get().asFile.absolutePath}"
dependsOn shadowJar
}
}