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.trace.agent.integration.*", 'com.datadoghq.trace.agent.AnnotationsTracingAgent', 'com.datadoghq.trace.agent.AgentTracerConfig', 'com.datadoghq.trace.agent.TraceAnnotationsManager', 'com.datadoghq.trace.agent.InstrumentationChecker', 'com.datadoghq.trace.agent.DDJavaAgentInfo', 'io.opentracing.contrib.mongo.TracingCommandListenerFactory', 'com.datadoghq.trace.agent.InstrumentationChecker.1', 'com.datadoghq.trace.agent.InstrumentationChecker.ArtifactSupport', ] dependencies { compile project(':dd-trace') compile project(':dd-trace-annotations') compile(project(path: ':dd-java-agent:integrations:helpers', configuration: "shadow")) { transitive = false } compile group: 'io.opentracing.contrib', name: 'opentracing-agent', version: '0.1.0' compile group: 'org.reflections', name: 'reflections', version: '0.9.11' compile group: 'com.google.auto.service', name: 'auto-service', version: '1.0-rc3' compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25' // ^ Generally a bad idea for libraries, but we're shadowing. testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' testCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2' testCompile group: 'io.opentracing', name: 'opentracing-mock', version: '0.30.0' // Not bundled in with the agent. Usage requires being on the app's classpath (eg. Spring Boot's executable jar) compileOnly group: 'io.opentracing.contrib', name: 'opentracing-jdbc', version: '0.0.3' } project(':dd-java-agent:integrations:helpers').afterEvaluate { helperProject -> project.compileJava.dependsOn helperProject.tasks.shadowJar } jar { classifier = 'unbundled' manifest { attributes( "Main-Class": "com.datadoghq.trace.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.AnnotationsTracingAgent", "Premain-Class": "com.datadoghq.trace.agent.AnnotationsTracingAgent", "Can-Redefine-Classes": true, "Can-Retransform-Classes": true, // It is dangerous putting everything on the bootstrap classpath, // but kept for consistency with previous versions. "Boot-Class-Path": "./${jar.archiveName}.jar" ) } } shadowJar { classifier null // mergeServiceFiles() relocate 'org.slf4j', 'dd.slf4j' // Prevents conflict with other SLF4J instances. Important for premain. if (!project.hasProperty("disableShadowRelocate") || !disableShadowRelocate) { // Don't relocate opentracing deps. relocate 'org.yaml', 'dd.deps.org.yaml' relocate 'org.msgpack', 'dd.deps.org.msgpack' relocate('com.fasterxml', 'dd.deps.com.fasterxml') { exclude 'com.fasterxml.jackson.core.type.TypeReference' exclude 'com.fasterxml.jackson.annotation.*' } relocate 'javassist', 'dd.deps.javassist' relocate 'org.reflections', 'dd.deps.org.reflections' 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' } } //Exclude Java 9 compiled classes: exclude 'org/jboss/byteman/agent/JigsawAccessEnablerGenerator.class' exclude 'org/jboss/byteman/agent/JigsawAccessManager$1.class' exclude 'org/jboss/byteman/agent/JigsawAccessManager.class' exclude 'org/jboss/byteman/layer/LayerFactory.class' exclude 'org/jboss/byteman/layer/LayerModuleFinder$1.class' exclude 'org/jboss/byteman/layer/LayerModuleFinder.class' exclude 'org/jboss/byteman/layer/LayerModuleReader.class' exclude 'org/jboss/byteman/layer/LayerModuleReference.class' 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 } }