forked from DataDog/dd-trace-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdd-java-agent.gradle
More file actions
131 lines (105 loc) · 3.89 KB
/
dd-java-agent.gradle
File metadata and controls
131 lines (105 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
plugins {
id "com.github.johnrengelman.shadow" version "4.0.4"
}
// Set properties before any plugins get loaded
project.ext {
// Execute tests on all JVMs, even rare and outdated ones
integrationTests = true
}
description = 'dd-java-agent'
apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/publish.gradle"
/*
* Include subproject's shadowJar in the dd-java-agent jar.
* Note jarname must end in .zip, 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(subproject.tasks.shadowJar)
rename {
it.equals(subproject.shadowJar.archivePath.getName()) ?
jarname :
it
}
}
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:agent-bootstrap'), 'agent-bootstrap.jar.zip')
includeShadowJar(project(':dd-java-agent:instrumentation'), 'agent-tooling-and-instrumentation.jar.zip')
includeShadowJar(project(':dd-java-agent:agent-jmxfetch'), 'agent-jmxfetch.jar.zip')
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 {
classifier null
mergeServiceFiles()
dependencies {
exclude(dependency("org.projectlombok:lombok:$versions.lombok"))
}
}
// 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
testCompile group: 'org.assertj', name: 'assertj-core', version: '2.9.+'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.19.0'
testCompile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2'
testCompile group: 'org.mongodb', name: 'mongodb-driver-async', version: '3.4.2'
// run embeded mongodb for integration testing
testCompile group: 'de.flapdoodle.embed', name: 'de.flapdoodle.embed.mongo', version: '1.50.5'
testCompile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.3'
testCompile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
}
tasks.withType(Test).configureEach {
jvmArgs "-Ddd.writer.type=LogWriter", "-Ddd.service.name=java-app"
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
}