opentelemetry-java-instrume.../dd-java-agent/dd-java-agent.gradle

124 lines
3.7 KiB
Groovy

plugins {
id "com.github.johnrengelman.shadow" version "2.0.1"
}
description = 'dd-java-agent'
apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/publish.gradle"
apply from: "${rootDir}/gradle/jacoco.gradle"
jacocoTestReport.dependsOn ':dd-java-agent-ittests:test'
whitelistedInstructionClasses += whitelistedBranchClasses += [
'com.datadoghq.agent.*',
'com.datadoghq.agent.integration.*',
'io.opentracing.contrib.*',
'dd.opentracing.contrib.*',
]
dependencies {
compile project(':dd-trace')
compile project(':dd-java-agent:tooling')
compile project(':dd-trace-annotations')
compile(project(':dd-java-agent:integrations:aws-sdk')) {
transitive = false
}
compile(project(':dd-java-agent:integrations:servlet-2')) {
transitive = false
}
compile(project(':dd-java-agent:integrations:servlet-3')) {
transitive = false
}
compile(project(':dd-java-agent:integrations:spring-web')) {
transitive = false
}
compile deps.bytebuddy
compile group: 'org.jboss.byteman', name: 'byteman', version: '3.0.10'
compile deps.autoservice
compile deps.slf4j
compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
// ^ Generally a bad idea for libraries, but we're shadowing.
testCompile deps.testLogging
testCompile deps.opentracingMock
testCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2'
testCompile(project(path: ':dd-java-agent:integrations:helpers')) {
transitive = false
}
}
project(':dd-java-agent:integrations:helpers').afterEvaluate { helperProject ->
project.processResources {
from(helperProject.tasks.shadowJar)
rename {
it.startsWith("helpers") && it.endsWith(".jar") ?
"helpers.jar.zip" :
it
}
}
project.processResources.dependsOn helperProject.tasks.shadowJar
}
jar {
classifier = 'unbundled'
manifest {
attributes(
"Main-Class": "com.datadoghq.agent.DDJavaAgentInfo",
// I don't think we want to define this since we can't really load after startup:
//"Agent-Class": "com.datadoghq.trace.agent.TracingAgent",
"Premain-Class": "com.datadoghq.agent.TracingAgent",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true,
)
}
}
shadowJar {
classifier null
mergeServiceFiles() // This triggers shadow to also apply the relocate rules below to the service files.
relocate 'org.slf4j', 'dd.slf4j' // Prevents conflict with other SLF4J instances. Important for premain.
if (!project.hasProperty("disableShadowRelocate") || !disableShadowRelocate) {
// These need to be relocated to prevent conflicts in case the regular dd-trace is already on the classpath.
relocate('com.datadoghq.trace', 'com.datadoghq.agent.tracer') {
// We want to ensure to not miss if a user is using the annotation.
exclude 'com.datadoghq.trace.Trace'
}
relocate 'io.opentracing.contrib', 'dd.opentracing.contrib'
relocate 'org.yaml', 'dd.deps.org.yaml'
relocate 'org.msgpack', 'dd.deps.org.msgpack'
relocate 'com.fasterxml', 'dd.deps.com.fasterxml'
relocate 'net.bytebuddy', 'dd.deps.net.bytebuddy'
relocate('org.jboss.byteman', 'dd.deps.org.jboss.byteman') {
// Renaming these causes a verify error in the tests.
exclude 'org.jboss.byteman.rule.*'
exclude 'org.jboss.byteman.rule.helper.*'
}
relocate('com.google', 'dd.deps.com.google') {
// This is used in the Cassandra Cluster.connectAsync signature so we can't relocate it. :fingers_crossed:
exclude 'com.google.common.util.concurrent.ListenableFuture'
}
}
dependencies {
exclude(dependency('org.projectlombok:lombok:1.16.18'))
}
}
// We don't want bundled dependencies to show up in the pom.
modifyPom {
dependencies.removeAll { true }
}