Skip to content

Commit e553ae7

Browse files
authored
Another batch of lazy API changes (#9737)
* chore: Lazy task access * chore: Lazy task access * chore: Lazy task access for classpath, removes non-needed dependsOn Since the classpath is properly declared the task dependency is not necessary anymore. * chore: Lazy configurations access * chore: Lazy configurations access for instrument project * chore: Lazy task access * style: make spotless happy
1 parent 85d8580 commit e553ae7

File tree

39 files changed

+172
-193
lines changed

39 files changed

+172
-193
lines changed

dd-java-agent/agent-otel/otel-bootstrap/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ apply from: "$rootDir/gradle/java.gradle"
1111
apply plugin: 'instrument'
1212

1313
configurations {
14-
embeddedClasspath {
14+
def ec = register('embeddedClasspath') {
1515
visible = false
1616
canBeConsumed = false
1717
canBeResolved = true
1818
}
19-
compileClasspath.extendsFrom(embeddedClasspath)
19+
named('compileClasspath') {
20+
compileClasspath.extendsFrom(ec.get())
21+
}
2022
instrumentPluginClasspath {
2123
visible = false
2224
canBeConsumed = false
@@ -55,13 +57,12 @@ dependencies {
5557

5658
// unpack embeddedClasspath to same path as compiled classes so it can get instrumented
5759
tasks.register('unpackJars', Copy) {
58-
dependsOn configurations.embeddedClasspath
60+
dependsOn configurations.named('embeddedClasspath')
5961
exclude 'META-INF/'
6062
exclude '**/module-info.class'
6163
exclude '**/package-info.class'
62-
from {
63-
configurations.embeddedClasspath.collect { zipTree(it) }
64-
}
64+
65+
from(configurations.named('embeddedClasspath').map { it.collect { zipTree(it) } })
6566
into compileJava.destinationDirectory
6667
}
6768

dd-java-agent/appsec/appsec-test-fixtures/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ dependencies {
66
api project(':dd-java-agent:instrumentation-testing')
77
}
88

9-
configurations.api {
9+
configurations.named('api') {
1010
exclude group: 'org.eclipse.jetty', module: 'jetty-server'
1111
}

dd-java-agent/instrumentation/akka/akka-http/akka-http-10.0/build.gradle

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,31 +171,25 @@ dependencies {
171171
}
172172

173173
tasks.named("compileBaseTestGroovy", GroovyCompile) {
174-
classpath = classpath.plus(files(compileBaseTestScala.destinationDirectory))
175-
dependsOn "compileBaseTestScala"
174+
classpath += files(tasks.named('compileBaseTestScala').map { it.destinationDirectory })
176175
}
177176

178177
tasks.named("compileBaseForkedTestGroovy", GroovyCompile) {
179-
classpath = classpath.plus(files(compileBaseTestScala.destinationDirectory))
180-
dependsOn "compileBaseTestScala"
178+
classpath += files(tasks.named('compileBaseTestScala').map { it.destinationDirectory })
181179
}
182180

183181
tasks.named("compileVersion101TestGroovy", GroovyCompile) {
184-
classpath = classpath.plus(files(compileVersion101TestScala.destinationDirectory))
185-
dependsOn "compileVersion101TestScala"
182+
classpath += files(tasks.named('compileVersion101TestScala').map { it.destinationDirectory })
186183
}
187184

188185
tasks.named("compileVersion101ForkedTestGroovy", GroovyCompile) {
189-
classpath = classpath.plus(files(compileVersion101TestScala.destinationDirectory))
190-
dependsOn "compileVersion101TestScala"
186+
classpath += files(tasks.named('compileVersion101TestScala').map { it.destinationDirectory })
191187
}
192188

193189
tasks.named("compileVersion102Scala213TestGroovy", GroovyCompile) {
194-
classpath = classpath.plus(files(compileVersion102Scala213TestScala.destinationDirectory))
195-
dependsOn "compileVersion102Scala213TestScala"
190+
classpath += files(tasks.named('compileVersion102Scala213TestScala').map { it.destinationDirectory })
196191
}
197192

198193
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
199-
classpath = classpath.plus(files(compileLatestDepTestScala.destinationDirectory))
200-
dependsOn "compileLatestDepTestScala"
194+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
201195
}

dd-java-agent/instrumentation/akka/akka-http/akka-http-10.6/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,12 @@ addTestSuiteForDir('latestDepTest', 'test')
4747

4848
tasks.named("compileTestGroovy", GroovyCompile) {
4949
configureCompiler(it, 11)
50-
dependsOn compileTestScala
51-
classpath += files(compileTestScala.destinationDirectory)
50+
classpath += files(tasks.named('compileTestScala').map { it.destinationDirectory })
5251
}
5352

5453
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
5554
configureCompiler(it, 11)
56-
dependsOn compileLatestDepTestScala
57-
classpath += files(compileLatestDepTestScala.destinationDirectory)
55+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
5856
}
5957

6058
dependencies {

dd-java-agent/instrumentation/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ subprojects { Project subProj ->
3939
def name = "java$version.majorVersion"
4040
jdkCompile = "main_${name}Implementation"
4141
}
42-
configurations.muzzleBootstrap {
42+
configurations.named('muzzleBootstrap') {
4343
exclude group: 'org.snakeyaml', module: 'snakeyaml-engine' // we vendor this in the agent jar
4444
}
4545
dependencies {

dd-java-agent/instrumentation/cxf-2.1/build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,16 @@ dependencies {
7575
latestDepTestCompileOnly group: 'jakarta.ws.rs', name: 'jakarta.ws.rs-api', version: '3.+'
7676
latestDepTestImplementation group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxrs', version: '+'
7777
latestDepTestImplementation group: 'org.apache.cxf', name:'cxf-rt-transports-http-jetty', version: '+'
78+
}
79+
80+
configurations.named('latestDepTestRuntimeClasspath') {
81+
resolutionStrategy {
82+
force libs.slf4j
83+
}
84+
}
7885

79-
configurations.findAll {it.name in ['latestDepTestRuntimeClasspath', 'cxf3LatestDepTestRuntimeClasspath'] }.each {
80-
it.resolutionStrategy {
81-
force libs.slf4j
82-
}
86+
configurations.named('cxf3LatestDepTestRuntimeClasspath') {
87+
resolutionStrategy {
88+
force libs.slf4j
8389
}
8490
}

dd-java-agent/instrumentation/elasticsearch/rest-5/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ dependencies {
4646
latestDepTestImplementation group: 'org.elasticsearch.plugin', name: 'transport-netty4-client', version: '6.3.+'
4747
}
4848

49-
configurations.latestDepTestImplementation {
49+
configurations.named('latestDepTestImplementation') {
5050
exclude group: "org.elasticsearch.client", module: "rest"
5151
}

dd-java-agent/instrumentation/finatra-2.9/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ dependencies {
3636
}
3737

3838
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
39-
classpath = classpath.plus(files(compileLatestDepTestScala.destinationDirectory))
39+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
4040
dependsOn "compileLatestDepTestScala"
4141
}
4242

4343
tasks.named("compileLatestPre207TestGroovy", GroovyCompile) {
44-
classpath = classpath.plus(files(compileLatestPre207TestScala.destinationDirectory))
44+
classpath += files(tasks.named('compileLatestPre207TestScala').map { it.destinationDirectory })
4545
dependsOn "compileLatestPre207TestScala"
4646
}
4747

4848
tasks.named("latestDepTest", Test) {
49-
finalizedBy latestPre207Test
49+
finalizedBy 'latestPre207Test'
5050
}

dd-java-agent/instrumentation/grizzly/grizzly-2.0/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ dependencies {
2626
latestDepTestImplementation group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.+'
2727
}
2828

29-
configurations.testRuntimeOnly {
29+
configurations.named('testRuntimeOnly') {
3030
// jersey-container-grizzly2-http transitively imports its own set repackaged asm classes
3131
exclude group: 'org.ow2.asm'
3232
}

dd-java-agent/instrumentation/jdbc/scalikejdbc/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ addTestSuiteForDir('latestDepTest', 'test')
1212

1313
tasks.named("compileTestGroovy", GroovyCompile) {
1414
dependsOn "compileTestScala"
15-
classpath += files(compileTestScala.destinationDirectory)
15+
classpath += files(tasks.named('compileTestScala').map { it.destinationDirectory })
1616
}
1717

1818
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
1919
dependsOn "compileLatestDepTestScala"
20-
classpath += files(compileLatestDepTestScala.destinationDirectory)
20+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
2121
}
2222

2323
tasks.withType(ScalaCompile).configureEach {

0 commit comments

Comments
 (0)