137 lines
3.9 KiB
Groovy
137 lines
3.9 KiB
Groovy
plugins {
|
|
id "com.github.johnrengelman.shadow" version "4.0.4"
|
|
}
|
|
|
|
description = 'dd-java-agent'
|
|
|
|
apply from: "${rootDir}/gradle/java.gradle"
|
|
apply from: "${rootDir}/gradle/publish.gradle"
|
|
|
|
configurations {
|
|
shadowInclude
|
|
}
|
|
/*
|
|
* Include subproject's shadowJar in the dd-java-agent jar.
|
|
* Note jarname must not end with '.jar', or its classes will be on the classpath of
|
|
* the dd-java-agent jar.
|
|
*/
|
|
|
|
def includeShadowJar(subproject, jarname) {
|
|
def agent_project = project
|
|
subproject.afterEvaluate {
|
|
agent_project.processResources {
|
|
from(zipTree(subproject.tasks.shadowJar.archivePath)) {
|
|
into jarname
|
|
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'
|
|
}
|
|
}
|
|
|
|
agent_project.processResources.dependsOn subproject.tasks.shadowJar
|
|
subproject.shadowJar {
|
|
classifier null
|
|
|
|
mergeServiceFiles()
|
|
|
|
exclude '**/module-info.class'
|
|
|
|
dependencies {
|
|
exclude(dependency("org.projectlombok:lombok:$versions.lombok"))
|
|
}
|
|
|
|
// Prevents conflict with other SLF4J instances. Important for premain.
|
|
relocate 'org.slf4j', 'datadog.slf4j'
|
|
// rewrite dependencies calling Logger.getLogger
|
|
relocate 'java.util.logging.Logger', 'datadog.trace.bootstrap.PatchLogger'
|
|
|
|
if (!project.hasProperty("disableShadowRelocate") || !disableShadowRelocate) {
|
|
// shadow OT impl to prevent casts to implementation
|
|
relocate 'datadog.trace.common', 'datadog.trace.agent.common'
|
|
relocate 'datadog.opentracing', 'datadog.trace.agent.ot'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
includeShadowJar(project(':dd-java-agent:instrumentation'), 'agent-tooling-and-instrumentation.isolated')
|
|
|
|
jar {
|
|
classifier = 'unbundled'
|
|
|
|
manifest {
|
|
attributes(
|
|
"Main-Class": "datadog.trace.agent.TracingAgent",
|
|
"Agent-Class": "datadog.trace.agent.TracingAgent",
|
|
"Premain-Class": "datadog.trace.agent.TracingAgent",
|
|
"Can-Redefine-Classes": true,
|
|
"Can-Retransform-Classes": true,
|
|
)
|
|
}
|
|
}
|
|
|
|
shadowJar {
|
|
configurations = [project.configurations.shadowInclude]
|
|
|
|
classifier null
|
|
|
|
mergeServiceFiles()
|
|
|
|
exclude '**/module-info.class'
|
|
|
|
dependencies {
|
|
exclude(dependency("org.projectlombok:lombok:$versions.lombok"))
|
|
}
|
|
|
|
// Prevents conflict with other SLF4J instances. Important for premain.
|
|
relocate 'org.slf4j', 'datadog.slf4j'
|
|
// rewrite dependencies calling Logger.getLogger
|
|
relocate 'java.util.logging.Logger', 'datadog.trace.bootstrap.PatchLogger'
|
|
|
|
if (!project.hasProperty("disableShadowRelocate") || !disableShadowRelocate) {
|
|
// shadow OT impl to prevent casts to implementation
|
|
relocate 'datadog.trace.common', 'datadog.trace.agent.common'
|
|
relocate 'datadog.opentracing', 'datadog.trace.agent.ot'
|
|
}
|
|
}
|
|
|
|
// We don't want bundled dependencies to show up in the pom.
|
|
modifyPom {
|
|
dependencies.removeAll { true }
|
|
}
|
|
|
|
dependencies {
|
|
testCompile project(':dd-trace-api')
|
|
testCompile project(':dd-trace-ot')
|
|
testCompile project(':utils:gc-utils')
|
|
|
|
testCompile deps.opentracingMock
|
|
testCompile deps.testLogging
|
|
testCompile deps.guava
|
|
|
|
shadowInclude project(':dd-java-agent:agent-bootstrap')
|
|
}
|
|
|
|
tasks.withType(Test).configureEach {
|
|
jvmArgs "-Ddd.service.name=java-agent-tests"
|
|
jvmArgs "-Ddd.writer.type=LoggingWriter"
|
|
// Multi-threaded logging seems to be causing deadlocks with Gradle's log capture.
|
|
// jvmArgs "-Ddatadog.slf4j.simpleLogger.defaultLogLevel=debug"
|
|
// jvmArgs "-Dorg.slf4j.simpleLogger.defaultLogLevel=debug"
|
|
|
|
doFirst {
|
|
// Defining here to allow jacoco to be first on the command line.
|
|
jvmArgs "-javaagent:${shadowJar.archivePath}"
|
|
}
|
|
|
|
testLogging {
|
|
events "started"
|
|
}
|
|
|
|
if (project.hasProperty("disableShadowRelocate") && disableShadowRelocate) {
|
|
exclude 'datadog/trace/agent/integration/classloading/ShadowPackageRenamingTest.class'
|
|
}
|
|
|
|
dependsOn shadowJar
|
|
}
|