-
Notifications
You must be signed in to change notification settings - Fork 337
Expand file tree
/
Copy pathbuild.gradle
More file actions
180 lines (152 loc) · 6.26 KB
/
build.gradle
File metadata and controls
180 lines (152 loc) · 6.26 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// this project will run in isolation under the agent's classloader
buildscript {
repositories {
mavenLocal()
if (project.rootProject.hasProperty("gradlePluginProxy")) {
maven {
url project.rootProject.property("gradlePluginProxy")
allowInsecureProtocol = true
}
}
if (project.rootProject.hasProperty("mavenRepositoryProxy")) {
maven {
url project.rootProject.property("mavenRepositoryProxy")
allowInsecureProtocol = true
}
}
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: libs.versions.kotlin.get()
}
}
plugins {
id 'com.gradleup.shadow'
}
apply from: "$rootDir/gradle/java.gradle"
tasks.register("latestDepTest")
Project parent_project = project
subprojects { Project subProj ->
apply plugin: 'instrument'
apply plugin: 'muzzle'
configurations {
instrumentPluginClasspath {
visible = false
canBeConsumed = false
canBeResolved = true
}
}
instrument.plugins = [
'datadog.trace.agent.tooling.muzzle.MuzzleGradlePlugin',
'datadog.trace.agent.tooling.bytebuddy.NewTaskForGradlePlugin',
'datadog.trace.agent.tooling.bytebuddy.reqctx.RewriteRequestContextAdvicePlugin',
]
subProj.tasks.withType(Javadoc).configureEach { enabled = false }
subProj.afterEvaluate {
if (!plugins.hasPlugin("java")) {
return
}
String jdkCompile = null
if (project.hasProperty('minJavaVersionForTests') && project.getProperty('minJavaVersionForTests') != JavaVersion.VERSION_1_8) {
def version = JavaVersion.toVersion(project.getProperty('minJavaVersionForTests'))
def name = "java$version.majorVersion"
jdkCompile = "main_${name}Implementation"
}
configurations.muzzleBootstrap {
exclude group: 'org.snakeyaml', module: 'snakeyaml-engine' // we vendor this in the agent jar
}
dependencies {
// Apply common dependencies for instrumentation.
implementation project(':dd-trace-api')
implementation project(':dd-java-agent:agent-tooling')
implementation libs.bytebuddy
if (jdkCompile) {
"$jdkCompile" project(':dd-trace-api')
"$jdkCompile" project(':dd-java-agent:agent-tooling')
"$jdkCompile" libs.bytebuddy
}
annotationProcessor project(':dd-java-agent:instrumentation-annotation-processor')
annotationProcessor libs.autoservice.processor
compileOnly libs.autoservice.annotation
// Include instrumentations instrumenting core JDK classes to ensure interoperability with other instrumentation
testImplementation project(':dd-java-agent:instrumentation:java-concurrent')
testImplementation project(':dd-java-agent:instrumentation:java-concurrent:java-completablefuture')
// FIXME: we should enable this, but currently this fails tests for google http client
//testImplementation project(':dd-java-agent:instrumentation:http-url-connection')
testImplementation project(':dd-java-agent:instrumentation:classloading')
testImplementation project(':dd-java-agent:instrumentation-testing')
testAnnotationProcessor libs.autoservice.processor
testCompileOnly libs.autoservice.annotation
instrumentPluginClasspath project(path: ':dd-java-agent:agent-tooling', configuration: 'instrumentPluginClasspath')
}
subProj.tasks.withType(Test).configureEach { subTask ->
if (subTask.name in ['latestDepTest', 'latestDepForkedTest']) {
subTask.jvmArgs '-Dtest.dd.latestDepTest=true'
}
}
}
def path = subProj.getPath()
subProj.plugins.withId("java") {
if (!path.equals(':dd-java-agent:instrumentation:vertx:vertx-redis-client-3.9:stubs')) {
// don't include the redis RequestImpl stub
parent_project.dependencies {
implementation project(path)
}
}
}
}
dependencies {
implementation(project(':dd-java-agent:agent-tooling')) {
exclude module: ':dd-java-agent:agent-bootstrap'
}
implementation project(':dd-java-agent:agent-builder')
}
if (project.gradle.startParameter.taskNames.any { it.endsWith("generateMuzzleReport") }) {
apply plugin: 'muzzle'
task("muzzleInstrumentationReport") {
dependsOn(project.getAllTasks(true).values().flatten().findAll { it.name.endsWith("generateMuzzleReport") })
finalizedBy(tasks.named('mergeMuzzleReports'))
}
}
tasks.named('shadowJar') {
duplicatesStrategy = DuplicatesStrategy.FAIL
dependencies {
// the tracer is now in a separate shadow jar
exclude(project(":dd-trace-core"))
exclude(dependency('com.datadoghq:sketches-java'))
exclude(dependency('com.google.re2j:re2j'))
}
dependencies deps.excludeShared
}
tasks.register('generateInstrumenterIndex', JavaExec) {
// temporary config to add slf4j-simple so we get logging from instrumenters while indexing
def slf4jSimple = project.configurations.maybeCreate('slf4j-simple')
project.dependencies.add('slf4j-simple', "org.slf4j:slf4j-simple:${libs.versions.slf4j.get()}")
def resourcesDir = "${sourceSets.main.output.resourcesDir}"
def indexFile = "${resourcesDir}/instrumenter.index"
it.group = 'Build'
it.description = "Generate instrumenter.index"
it.mainClass = 'datadog.trace.agent.tooling.InstrumenterIndex$IndexGenerator'
it.classpath = project.configurations.runtimeClasspath + slf4jSimple
it.inputs.files(it.classpath)
it.outputs.files(indexFile)
it.args = [resourcesDir]
dependsOn 'processResources'
}
tasks.register('generateKnownTypesIndex', JavaExec) {
// temporary config to add slf4j-simple so we get logging from instrumenters while indexing
def slf4jSimple = project.configurations.maybeCreate('slf4j-simple')
project.dependencies.add('slf4j-simple', "org.slf4j:slf4j-simple:${libs.versions.slf4j.get()}")
def resourcesDir = "${sourceSets.main.output.resourcesDir}"
def indexFile = "${resourcesDir}/known-types.index"
it.group = 'Build'
it.description = "Generate known-types.index"
it.mainClass = 'datadog.trace.agent.tooling.KnownTypesIndex$IndexGenerator'
it.classpath = project.configurations.runtimeClasspath + slf4jSimple
it.inputs.files(it.classpath)
it.outputs.files(indexFile)
it.args = [resourcesDir]
dependsOn 'processResources'
}
shadowJar.dependsOn 'generateInstrumenterIndex', 'generateKnownTypesIndex'