-
Notifications
You must be signed in to change notification settings - Fork 357
Expand file tree
/
Copy pathbuild.gradle
More file actions
195 lines (163 loc) · 7 KB
/
Copy pathbuild.gradle
File metadata and controls
195 lines (163 loc) · 7 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// 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.github.johnrengelman.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 {
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"
}
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:testing')
testAnnotationProcessor libs.autoservice.processor
testCompileOnly libs.autoservice.annotation
instrumentPluginClasspath project(path: ':dd-java-agent:agent-tooling', configuration: 'instrumentPluginClasspath')
}
subProj.testing {
suites.configureEach {
// SpockRunner that we use to run agent tests cannot be properly ported to JUnit 5,
// since the framework does not provide the hooks / extension points
// that can be used to shadow the tested class.
// In order to mitigate this, SpockRunner extends JUnitPlatform,
// which is a JUnit 4 runner that allows executing JUnit 5 tests in a JUnit 4 environment
// (i.e. running them as JUnit 4 tests).
// So even though Spock 2 tests run on top of JUnit 5,
// we execute them in "compatibility mode" so that SpockRunner could shadow the test class
// See https://junit.org/junit5/docs/current/user-guide/#running-tests-junit-platform-runner for more details.
useJUnit()
}
}
subProj.tasks.withType(Test).configureEach { subTask ->
// The `forkedTest` task is not a proper test suite, so it has to be configured directly
if (subTask.name == 'forkedTest') {
// See SpockRunner comment above
useJUnit()
}
if (subTask.name in ['latestDepTest', 'latestDepForkedTest']) {
subTask.jvmArgs '-Dtest.dd.latestDepTest=true'
}
}
}
def path = subProj.getPath()
// don't include the redis RequestImpl stub
if (!path.equals(':dd-java-agent:instrumentation:vertx-redis-client-3.9:stubs')) {
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').configure {
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'