Skip to content

Commit ff71451

Browse files
committed
chore: Remove instrumentation afterEvaluate
# Conflicts: # dd-java-agent/instrumentation/build.gradle
1 parent 46649f7 commit ff71451

File tree

1 file changed

+41
-29
lines changed

1 file changed

+41
-29
lines changed

dd-java-agent/instrumentation/build.gradle

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,56 @@ tasks.register("latestDepTest", Test)
1010

1111
Project parent_project = project
1212
subprojects { Project subProj ->
13-
apply plugin: 'instrument'
14-
apply plugin: 'muzzle'
15-
16-
configurations {
17-
instrumentPluginClasspath {
18-
visible = false
19-
canBeConsumed = false
20-
canBeResolved = true
13+
subProj.pluginManager.withPlugin("instrument") {
14+
subProj.extensions.configure(InstrumentExtension) {
15+
it.plugins.addAll(
16+
'datadog.trace.agent.tooling.muzzle.MuzzleGradlePlugin',
17+
'datadog.trace.agent.tooling.bytebuddy.NewTaskForGradlePlugin',
18+
'datadog.trace.agent.tooling.bytebuddy.reqctx.RewriteRequestContextAdvicePlugin',
19+
)
2120
}
22-
}
2321

24-
instrument.plugins = [
25-
'datadog.trace.agent.tooling.muzzle.MuzzleGradlePlugin',
26-
'datadog.trace.agent.tooling.bytebuddy.NewTaskForGradlePlugin',
27-
'datadog.trace.agent.tooling.bytebuddy.reqctx.RewriteRequestContextAdvicePlugin',
28-
]
22+
subProj.configurations.register("instrumentPluginClasspath") {
23+
it.visible = false
24+
it.canBeConsumed = false
25+
it.canBeResolved = true
2926

30-
subProj.tasks.withType(Javadoc).configureEach { enabled = false }
27+
it.dependencies.add(subProj.dependencies.project(path: ':dd-java-agent:agent-tooling', configuration: 'instrumentPluginClasspath'))
28+
}
3129

32-
subProj.afterEvaluate {
33-
if (!plugins.hasPlugin("java")) {
34-
return
30+
}
31+
32+
subProj.pluginManager.withPlugin("java") {
33+
subProj.pluginManager.withPlugin("muzzle") {
34+
subProj.configurations.matching { it.name == 'muzzleBootstrap' }.configureEach {
35+
exclude group: 'org.snakeyaml', module: 'snakeyaml-engine' // we vendor this in the agent jar
36+
}
3537
}
3638

3739
// Configures base dependencies for additional sourceSet
38-
configurations
40+
subProj.configurations
3941
.matching { it.name.matches("${SourceSet.MAIN_SOURCE_SET_NAME}_java\\d+${JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME.capitalize()}") }
4042
.configureEach {
4143
it.dependencies.add(project.dependencyFactory.create(project(':dd-trace-api')))
4244
it.dependencies.add(project.dependencyFactory.create(project(':dd-java-agent:agent-tooling')))
4345
it.dependencies.addLater(libs.bytebuddy)
4446
}
4547

46-
configurations.named('muzzleBootstrap') {
47-
exclude group: 'org.snakeyaml', module: 'snakeyaml-engine' // we vendor this in the agent jar
48+
subProj.tasks.withType(Javadoc).configureEach { enabled = false }
49+
50+
if (subProj.hasProperty('minJavaVersionForTests') && subProj.findProperty('minJavaVersionForTests') != JavaVersion.VERSION_1_8) {
51+
def version = JavaVersion.toVersion(subProj.findProperty('minJavaVersionForTests'))
52+
def mainJavaConfigName = "main_name${version.majorVersion}Implementation"
53+
54+
configurations
55+
.matching {it.name == mainJavaConfigName }
56+
.configureEach {
57+
it.dependencies.add(subProj.dependencies.project(path: ':dd-trace-api'))
58+
it.dependencies.add(subProj.dependencies.project(path: ':dd-java-agent:agent-tooling'))
59+
it.dependencies.addLater(libs.bytebuddy)
60+
}
4861
}
62+
4963
dependencies {
5064
// Apply common dependencies for instrumentation.
5165
implementation project(':dd-trace-api')
@@ -65,26 +79,24 @@ subprojects { Project subProj ->
6579
testImplementation project(':dd-java-agent:instrumentation-testing')
6680
testAnnotationProcessor libs.autoservice.processor
6781
testCompileOnly libs.autoservice.annotation
68-
69-
instrumentPluginClasspath project(path: ':dd-java-agent:agent-tooling', configuration: 'instrumentPluginClasspath')
7082
}
7183

7284
subProj.tasks.withType(Test).configureEach { subTask ->
7385
if (subTask.name in ['latestDepTest', 'latestDepForkedTest']) {
7486
subTask.jvmArgs '-Dtest.dd.latestDepTest=true'
7587
}
7688
}
77-
}
7889

79-
def path = subProj.getPath()
80-
subProj.plugins.withId("java") {
81-
if (!path.equals(':dd-java-agent:instrumentation:vertx:vertx-redis-client-3.9:stubs')) {
82-
// don't include the redis RequestImpl stub
90+
if (subProj.path != ':dd-java-agent:instrumentation:vertx:vertx-redis-client-3.9:stubs') {
91+
// don't include the redis RequestImpl stubs
8392
parent_project.dependencies {
84-
implementation project(path)
93+
addProvider("implementation", providers.provider { project(subProj.path) })
8594
}
8695
}
8796
}
97+
98+
subProj.apply plugin: 'instrument'
99+
subProj.apply plugin: 'muzzle'
88100
}
89101

90102
dependencies {

0 commit comments

Comments
 (0)