Skip to content

Commit 86d9a27

Browse files
committed
chore: Lazy task access for classpath, removes non-needed dependsOn
Since the classpath is properly declared the task dependency is not necessary anymore.
1 parent 79fb383 commit 86d9a27

File tree

13 files changed

+57
-87
lines changed

13 files changed

+57
-87
lines changed

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/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/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 {

dd-java-agent/instrumentation/junit/junit-4.10/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ kotlin {
2828
addTestSuiteForDir('latestDepTest', 'test')
2929

3030
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
31-
classpath += files(compileLatestDepTestKotlin.destinationDirectory)
31+
classpath += files(tasks.named('compileLatestDepTestKotlin').map { it.destinationDirectory })
3232
}
3333

3434
dependencies {

dd-java-agent/instrumentation/kotlin-coroutines/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ kotlin {
3939
addTestSuite('latestDepTest')
4040

4141
tasks.named("compileTestFixturesGroovy", GroovyCompile) {
42-
classpath += files(compileTestFixturesKotlin.destinationDirectory)
42+
classpath += files(tasks.named('compileTestFixturesKotlin').map { it.destinationDirectory })
4343
}
4444

4545
tasks.named("compileTestGroovy", GroovyCompile) {
46-
classpath += files(compileTestKotlin.destinationDirectory)
46+
classpath += files(tasks.named('compileTestKotlin').map { it.destinationDirectory })
4747
}
4848

4949
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
50-
classpath += files(compileLatestDepTestKotlin.destinationDirectory)
50+
classpath += files(tasks.named('compileLatestDepTestKotlin').map { it.destinationDirectory })
5151
}
5252

5353
dependencies {

dd-java-agent/instrumentation/pekko/pekko-http-1.0/build.gradle

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,13 @@ tasks.named("latestDepTest", Test) {
118118
}
119119

120120
tasks.named("compileBaseTestGroovy", GroovyCompile) {
121-
classpath = classpath.plus(files(compileBaseTestScala.destinationDirectory))
122-
dependsOn "compileBaseTestScala"
121+
classpath += files(tasks.named('compileBaseTestScala').map { it.destinationDirectory })
123122
}
124123

125124
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
126-
classpath = classpath.plus(files(compileLatestDepTestScala.destinationDirectory))
127-
dependsOn "compileLatestDepTestScala"
125+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
128126
}
129127

130128
tasks.named("compileLatestPekko10TestGroovy", GroovyCompile) {
131-
classpath = classpath.plus(files(compileLatestDepTestScala.destinationDirectory))
132-
dependsOn "compileLatestDepTestScala"
129+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
133130
}

dd-java-agent/instrumentation/play/play-2.3/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,5 @@ dependencies {
6060
}
6161

6262
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
63-
classpath = classpath.plus(files(compileLatestDepTestScala.destinationDirectory))
64-
dependsOn compileLatestDepTestScala
63+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
6564
}

dd-java-agent/instrumentation/play/play-2.4/build.gradle

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ tasks.named("jar", Jar) {
6262
from sourceSets.main_play25.output
6363
}
6464

65-
project.afterEvaluate { p ->
66-
instrumentJava.dependsOn compileMain_play25Java
67-
forbiddenApisMain_play25.dependsOn instrumentMain_play25Java
65+
project.afterEvaluate {
66+
tasks.named('instrumentJava') { dependsOn 'compileMain_play25Java' }
67+
tasks.named('forbiddenApisMain_play25') { dependsOn 'instrumentMain_play25Java' }
6868
}
6969

7070
instrument {
@@ -104,13 +104,11 @@ dependencies {
104104
}
105105

106106
tasks.named("compileTestGroovy", GroovyCompile) {
107-
classpath = classpath + files(compileTestScala.destinationDirectory)
108-
dependsOn 'compileTestScala'
107+
classpath = classpath + files(tasks.named('compileTestScala').map { it.destinationDirectory })
109108
}
110109

111110
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
112-
classpath = classpath + files(compileLatestDepTestScala.destinationDirectory)
113-
dependsOn 'compileLatestDepTestScala'
111+
classpath = classpath + files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
114112
}
115113

116114
sourceSets {
@@ -154,50 +152,42 @@ configurations {
154152
it.mainClass.set 'generator.CompileRoutes'
155153
it.args routesFile, outputDir.get().asFile.absolutePath
156154

157-
it.classpath configurations.routeGeneratorRuntimeClasspath
158-
it.classpath compileRouteGeneratorScala.destinationDirectory
155+
it.classpath configurations.named('routeGeneratorRuntimeClasspath')
156+
it.classpath tasks.named('compileRouteGeneratorScala').map { it.destinationDirectory }
159157

160158
if (taskName == 'buildTestRoutes') {
161-
it.classpath compileTestScala.destinationDirectory
162-
dependsOn compileTestScala
159+
it.classpath tasks.named('compileTestScala').map { it.destinationDirectory }
163160
} else {
164-
it.classpath compileLatestDepTestScala.destinationDirectory
165-
dependsOn compileLatestDepTestScala
161+
it.classpath tasks.named('compileLatestDepTestScala').map { it.destinationDirectory }
166162
}
167-
168-
dependsOn compileRouteGeneratorScala
169163
}
170164
}
171165

172166
tasks.named("compileTestGeneratedScala", ScalaCompile) {
173-
classpath = classpath + files(compileTestScala.destinationDirectory)
174-
dependsOn buildTestRoutes, compileLatestDepTestScala
167+
classpath += files(tasks.named('compileTestScala').map { it.destinationDirectory })
168+
dependsOn 'buildTestRoutes', 'compileLatestDepTestScala'
175169
}
176170

177171
tasks.named("compileLatestDepTestGeneratedScala", ScalaCompile) {
178-
classpath = classpath + files(compileLatestDepTestScala.destinationDirectory)
179-
dependsOn buildLatestDepTestRoutes, compileLatestDepTestScala
172+
classpath += files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
173+
dependsOn 'buildLatestDepTestRoutes'
180174
}
181175

182176
tasks.named("compileTestGroovy", GroovyCompile) {
183-
classpath = classpath +
184-
files(compileTestGeneratedScala.destinationDirectory)
185-
dependsOn 'compileTestGeneratedScala'
177+
classpath += files(tasks.named('compileTestGeneratedScala').map { it.destinationDirectory })
186178
}
187179

188180
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
189-
classpath = classpath +
190-
files(compileLatestDepTestGeneratedScala.destinationDirectory)
191-
dependsOn 'compileLatestDepTestGeneratedScala'
181+
classpath += files(tasks.named('compileLatestDepTestGeneratedScala').map { it.destinationDirectory })
192182
}
193183
// do it this way rather than through dependencies {} because
194184
// latestDepTestImplementation extends testImplementation
195185
tasks.named("test", Test) {
196-
classpath = classpath + files(compileTestGeneratedScala.destinationDirectory)
186+
classpath += files(tasks.named('compileTestGeneratedScala').map { it.destinationDirectory })
197187
}
198188

199189
tasks.named("latestDepTest", Test) {
200-
classpath = classpath + files(compileLatestDepTestGeneratedScala.destinationDirectory)
190+
classpath += files(tasks.named('compileLatestDepTestGeneratedScala').map { it.destinationDirectory })
201191
}
202192

203193
tasks.named("forbiddenApisTestGenerated") {

dd-java-agent/instrumentation/play/play-2.6/build.gradle

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ tasks.named("compileMain_play27Java", JavaCompile) {
8181
dependsOn(compileJava)
8282
}
8383

84-
project.afterEvaluate { p ->
85-
instrumentJava.dependsOn compileMain_play27Java
86-
forbiddenApisMain_play27.dependsOn instrumentMain_play27Java
84+
project.afterEvaluate {
85+
tasks.named('instrumentJava') { dependsOn 'compileMain_play27Java' }
86+
tasks.named('forbiddenApisMain_play27') { dependsOn 'instrumentMain_play27Java' }
8787
}
8888

8989
instrument {
@@ -140,8 +140,7 @@ tasks.named("compileLatestDepTestJava", JavaCompile) {
140140

141141
tasks.named("compileLatestDepTestScala", ScalaCompile) {
142142
configureCompiler(it, 11)
143-
classpath = classpath + files(compileBaseTestJava.destinationDirectory)
144-
dependsOn 'compileBaseTestJava'
143+
classpath = classpath + files(tasks.named('compileBaseTestJava').map { it.destinationDirectory })
145144
}
146145

147146
tasks.named("latestDepTest", Test) {
@@ -179,22 +178,20 @@ tasks.register('buildLatestDepTestRoutes', JavaExec) {
179178
it.inputs.file routesFile
180179
it.outputs.dir outputDir
181180

182-
it.mainClass.set 'generator.CompileRoutes'
181+
it.mainClass = 'generator.CompileRoutes'
183182
it.args routesFile, outputDir.get().asFile.absolutePath
184183

185-
it.classpath configurations.routeGeneratorRuntimeClasspath
186-
it.classpath compileRouteGeneratorScala.destinationDirectory
187-
it.classpath compileLatestDepTestScala.destinationDirectory
184+
it.classpath configurations.named('routeGeneratorRuntimeClasspath')
185+
it.classpath tasks.named('compileRouteGeneratorScala').map { it.destinationDirectory }
186+
it.classpath tasks.named('compileLatestDepTestScala').map { it.destinationDirectory }
188187

189-
it.javaLauncher.set getJavaLauncherFor(11)
190-
191-
dependsOn compileRouteGeneratorScala, compileLatestDepTestScala
188+
it.javaLauncher = getJavaLauncherFor(11)
192189
}
193190

194191
tasks.named("compileLatestDepTestGeneratedScala", ScalaCompile) {
195192
configureCompiler(it, 11)
196-
classpath = classpath + files(compileLatestDepTestScala.destinationDirectory)
197-
dependsOn buildLatestDepTestRoutes, compileLatestDepTestScala
193+
classpath = classpath + files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory })
194+
dependsOn 'buildLatestDepTestRoutes'
198195
}
199196

200197
tasks.named("forbiddenApisLatestDepTestGenerated") {
@@ -204,14 +201,10 @@ tasks.named("forbiddenApisLatestDepTestGenerated") {
204201
tasks.named("compileLatestDepTestGroovy", GroovyCompile) {
205202
configureCompiler(it, 11)
206203
classpath = classpath +
207-
files(compileLatestDepTestScala.destinationDirectory) +
208-
files(compileBaseTestGroovy.destinationDirectory) +
209-
files(compileBaseTestJava.destinationDirectory) +
210-
files(compileLatestDepTestGeneratedScala.destinationDirectory)
211-
dependsOn 'compileLatestDepTestScala'
212-
dependsOn 'compileBaseTestGroovy'
213-
dependsOn 'compileBaseTestJava'
214-
dependsOn 'compileLatestDepTestGeneratedScala'
204+
files(tasks.named('compileLatestDepTestScala').map { it.destinationDirectory }) +
205+
files(tasks.named('compileBaseTestGroovy').map { it.destinationDirectory }) +
206+
files(tasks.named('compileBaseTestJava').map { it.destinationDirectory }) +
207+
files(tasks.named('compileLatestDepTestGeneratedScala').map { it.destinationDirectory })
215208
}
216209

217210
dependencies {

0 commit comments

Comments
 (0)