Skip to content

Commit 73bd170

Browse files
committed
scoverage#163 Fix deprecation warning from Gradle 7.1.1 about undeclared dependency between report task and test tasks outputs
1 parent d7da6b1 commit 73bd170

14 files changed

+97
-49
lines changed

src/crossScalaVersionTest/java/org/scoverage/ScalaCrossVersionAggregationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void checkAndAggregateAll() throws Exception {
3030
private void assertAggregationFilesExist() {
3131

3232
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
33-
Assert.assertTrue(resolve(reportDir(), "2_12/src/main/scala/org/hello/World2_12.scala.html").exists());
34-
Assert.assertTrue(resolve(reportDir(), "2_13/src/main/scala/org/hello/World2_13.scala.html").exists());
33+
Assert.assertTrue(resolve(reportDir(), "org/hello/World2_12.scala.html").exists());
34+
Assert.assertTrue(resolve(reportDir(), "org/hello/World2_13.scala.html").exists());
3535
}
3636
}

src/crossScalaVersionTest/java/org/scoverage/ScalaVersionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ public void report() throws Exception {
2727

2828
File reportDir = reportDir(projectDir().toPath().resolve(scalaVersion).toFile());
2929
Assert.assertTrue(resolve(reportDir, "index.html").exists());
30-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/World" + scalaVersion + ".scala.html").exists());
30+
Assert.assertTrue(resolve(reportDir, "org/hello/World" + scalaVersion + ".scala.html").exists());
3131
}
32-
}
32+
}

src/functionalTest/java/org/scoverage/ScalaJavaAnnotationProcessorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ private void assertAllReportFilesExist() {
4444

4545
private void assertAggregationFilesExist() {
4646

47-
Assert.assertTrue(resolve(reportDir(), "mixed_scala_java/src/main/scala/org/hello/WorldScala.scala.html").exists());
47+
Assert.assertTrue(resolve(reportDir(), "org/hello/WorldScala.scala.html").exists());
4848
}
4949

5050
private void assertMixedScalaJavaReportFilesExist() {
5151

5252
File reportDir = reportDir(projectDir().toPath().resolve("mixed_scala_java").toFile());
5353
Assert.assertTrue(resolve(reportDir, "index.html").exists());
54-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/WorldScala.scala.html").exists());
54+
Assert.assertTrue(resolve(reportDir, "org/hello/WorldScala.scala.html").exists());
5555
}
5656
}

src/functionalTest/java/org/scoverage/ScalaJavaMultiModuleTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ private void assertAllReportFilesExist() {
4646

4747
private void assertAggregationFilesExist() {
4848

49-
Assert.assertTrue(resolve(reportDir(), "scala_only/src/main/scala/org/hello/WorldScalaOnly.scala.html").exists());
50-
Assert.assertTrue(resolve(reportDir(), "mixed_scala_java/src/main/scala/org/hello/WorldScala.scala.html").exists());
49+
Assert.assertTrue(resolve(reportDir(), "org/hello/WorldScalaOnly.scala.html").exists());
50+
Assert.assertTrue(resolve(reportDir(), "org/hello/WorldScala.scala.html").exists());
5151
}
5252

5353
private void assertScalaOnlyReportFilesExist() {
5454

5555
File reportDir = reportDir(projectDir().toPath().resolve("scala_only").toFile());
5656
Assert.assertTrue(resolve(reportDir, "index.html").exists());
57-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/WorldScalaOnly.scala.html").exists());
57+
Assert.assertTrue(resolve(reportDir, "org/hello/WorldScalaOnly.scala.html").exists());
5858
}
5959

6060
private void assertMixedScalaJavaReportFilesExist() {
6161

6262
File reportDir = reportDir(projectDir().toPath().resolve("mixed_scala_java").toFile());
6363
Assert.assertTrue(resolve(reportDir, "index.html").exists());
64-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/WorldScala.scala.html").exists());
64+
Assert.assertTrue(resolve(reportDir, "org/hello/WorldScala.scala.html").exists());
6565
}
6666
}

src/functionalTest/java/org/scoverage/ScalaMultiModuleTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,35 +297,35 @@ private void assertAllReportFilesExist() {
297297

298298
private void assertAggregationFilesExist() {
299299

300-
Assert.assertTrue(resolve(reportDir(), "a/src/main/scala/org/hello/a/WorldA.scala.html").exists());
301-
Assert.assertTrue(resolve(reportDir(), "b/src/main/scala/org/hello/b/WorldB.scala.html").exists());
302-
Assert.assertTrue(resolve(reportDir(), "common/src/main/scala/org/hello/common/WorldCommon.scala.html").exists());
300+
Assert.assertTrue(resolve(reportDir(), "org/hello/a/WorldA.scala.html").exists());
301+
Assert.assertTrue(resolve(reportDir(), "org/hello/b/WorldB.scala.html").exists());
302+
Assert.assertTrue(resolve(reportDir(), "org/hello/common/WorldCommon.scala.html").exists());
303303
}
304304

305305
private void assertRootReportFilesExist() {
306306

307307
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
308-
Assert.assertTrue(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
308+
Assert.assertTrue(resolve(reportDir(), "org/hello/World.scala.html").exists());
309309
}
310310

311311
private void assertAReportFilesExist() {
312312

313313
File reportDir = reportDir(projectDir().toPath().resolve("a").toFile());
314314
Assert.assertTrue(resolve(reportDir, "index.html").exists());
315-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/a/WorldA.scala.html").exists());
315+
Assert.assertTrue(resolve(reportDir, "org/hello/a/WorldA.scala.html").exists());
316316
}
317317

318318
private void assertBReportFilesExist() {
319319

320320
File reportDir = reportDir(projectDir().toPath().resolve("b").toFile());
321321
Assert.assertTrue(resolve(reportDir, "index.html").exists());
322-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/b/WorldB.scala.html").exists());
322+
Assert.assertTrue(resolve(reportDir, "org/hello/b/WorldB.scala.html").exists());
323323
}
324324

325325
private void assertCommonReportFilesExist() {
326326

327327
File reportDir = reportDir(projectDir().toPath().resolve("common").toFile());
328328
Assert.assertTrue(resolve(reportDir, "index.html").exists());
329-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/common/WorldCommon.scala.html").exists());
329+
Assert.assertTrue(resolve(reportDir, "org/hello/common/WorldCommon.scala.html").exists());
330330
}
331331
}

src/functionalTest/java/org/scoverage/ScalaMultiModuleWithMultipleTestTasksTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,35 +294,35 @@ private void assertAllReportFilesExist() {
294294

295295
private void assertAggregationFilesExist() {
296296

297-
Assert.assertTrue(resolve(reportDir(), "a/src/main/scala/org/hello/a/WorldA.scala.html").exists());
298-
Assert.assertTrue(resolve(reportDir(), "b/src/main/scala/org/hello/b/WorldB.scala.html").exists());
299-
Assert.assertTrue(resolve(reportDir(), "common/src/main/scala/org/hello/common/WorldCommon.scala.html").exists());
297+
Assert.assertTrue(resolve(reportDir(), "org/hello/a/WorldA.scala.html").exists());
298+
Assert.assertTrue(resolve(reportDir(), "org/hello/b/WorldB.scala.html").exists());
299+
Assert.assertTrue(resolve(reportDir(), "org/hello/common/WorldCommon.scala.html").exists());
300300
}
301301

302302
private void assertRootReportFilesExist() {
303303

304304
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
305-
Assert.assertTrue(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
305+
Assert.assertTrue(resolve(reportDir(), "org/hello/World.scala.html").exists());
306306
}
307307

308308
private void assertAReportFilesExist() {
309309

310310
File reportDir = reportDir(projectDir().toPath().resolve("a").toFile());
311311
Assert.assertTrue(resolve(reportDir, "index.html").exists());
312-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/a/WorldA.scala.html").exists());
312+
Assert.assertTrue(resolve(reportDir, "org/hello/a/WorldA.scala.html").exists());
313313
}
314314

315315
private void assertBReportFilesExist() {
316316

317317
File reportDir = reportDir(projectDir().toPath().resolve("b").toFile());
318318
Assert.assertTrue(resolve(reportDir, "index.html").exists());
319-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/b/WorldB.scala.html").exists());
319+
Assert.assertTrue(resolve(reportDir, "org/hello/b/WorldB.scala.html").exists());
320320
}
321321

322322
private void assertCommonReportFilesExist() {
323323

324324
File reportDir = reportDir(projectDir().toPath().resolve("common").toFile());
325325
Assert.assertTrue(resolve(reportDir, "index.html").exists());
326-
Assert.assertTrue(resolve(reportDir, "src/main/scala/org/hello/common/WorldCommon.scala.html").exists());
326+
Assert.assertTrue(resolve(reportDir, "org/hello/common/WorldCommon.scala.html").exists());
327327
}
328328
}

src/functionalTest/java/org/scoverage/ScalaSingleModuleTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void reportScoverageWithExcludedClasses() throws Exception {
9191
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
9292

9393
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
94-
Assert.assertFalse(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
94+
Assert.assertFalse(resolve(reportDir(), "org/hello/World.scala.html").exists());
9595
assertCoverage(100.0); // coverage is 100 since no classes are covered
9696

9797
// compiled class should exist in the default classes directory, but not in scoverage
@@ -125,7 +125,7 @@ public void reportScoverageWithoutNormalCompilationAndWithExcludedClasses() thro
125125
"-PexcludedFile=.*", "-P" + ScoveragePlugin.getSCOVERAGE_COMPILE_ONLY_PROPERTY());
126126

127127
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
128-
Assert.assertFalse(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
128+
Assert.assertFalse(resolve(reportDir(), "org/hello/World.scala.html").exists());
129129
assertCoverage(100.0); // coverage is 100 since no classes are covered
130130

131131
// compiled class should exist in the default classes directory, but not in scoverage
@@ -136,6 +136,6 @@ public void reportScoverageWithoutNormalCompilationAndWithExcludedClasses() thro
136136
private void assertReportFilesExist() {
137137

138138
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
139-
Assert.assertTrue(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
139+
Assert.assertTrue(resolve(reportDir(), "org/hello/World.scala.html").exists());
140140
}
141141
}

src/functionalTest/java/org/scoverage/ScalaSingleModuleWithDependencyManagerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public void checkScoverage() throws Exception {
2626
private void assertReportFilesExist() {
2727

2828
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
29-
Assert.assertTrue(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
29+
Assert.assertTrue(resolve(reportDir(), "org/hello/World.scala.html").exists());
3030
}
31-
}
31+
}

src/functionalTest/java/org/scoverage/ScalaSingleModuleWithMultipleTestTasksTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void reportScoverageWithExcludedClasses() throws Exception {
109109
result.assertTaskDoesntExist(ScoveragePlugin.getAGGREGATE_NAME());
110110

111111
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
112-
Assert.assertFalse(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
112+
Assert.assertFalse(resolve(reportDir(), "org/hello/World.scala.html").exists());
113113
assertCoverage(100.0); // coverage is 100 since no classes are covered
114114

115115
// compiled class should exist in the default classes directory, but not in scoverage
@@ -143,7 +143,7 @@ public void reportScoverageWithoutNormalCompilationAndWithExcludedClasses() thro
143143
"-PexcludedFile=.*", "-P" + ScoveragePlugin.getSCOVERAGE_COMPILE_ONLY_PROPERTY());
144144

145145
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
146-
Assert.assertFalse(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
146+
Assert.assertFalse(resolve(reportDir(), "org/hello/World.scala.html").exists());
147147
assertCoverage(100.0); // coverage is 100 since no classes are covered
148148

149149
// compiled class should exist in the default classes directory, but not in scoverage
@@ -155,6 +155,6 @@ public void reportScoverageWithoutNormalCompilationAndWithExcludedClasses() thro
155155
private void assertReportFilesExist() {
156156

157157
Assert.assertTrue(resolve(reportDir(), "index.html").exists());
158-
Assert.assertTrue(resolve(reportDir(), "src/main/scala/org/hello/World.scala.html").exists());
158+
Assert.assertTrue(resolve(reportDir(), "org/hello/World.scala.html").exists());
159159
}
160160
}

src/main/groovy/org/scoverage/ScoverageAggregate.groovy

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
package org.scoverage
22

33
import org.gradle.api.DefaultTask
4+
import org.gradle.api.file.FileCollection
45
import org.gradle.api.provider.ListProperty
56
import org.gradle.api.provider.Property
67
import org.gradle.api.tasks.Input
8+
import org.gradle.api.tasks.InputFiles
79
import org.gradle.api.tasks.Nested
810
import org.gradle.api.tasks.OutputDirectory
11+
import org.gradle.api.tasks.PathSensitive
912
import org.gradle.api.tasks.TaskAction
1013
import scoverage.report.CoverageAggregator
1114

15+
import static org.gradle.api.tasks.PathSensitivity.RELATIVE
16+
1217
class ScoverageAggregate extends DefaultTask {
1318

1419
@Nested
1520
ScoverageRunner runner
1621

22+
@InputFiles
23+
@PathSensitive(RELATIVE)
24+
final Property<FileCollection> sources = project.objects.property(FileCollection)
25+
1726
@OutputDirectory
1827
final Property<File> reportDir = project.objects.property(File)
1928

@@ -52,7 +61,7 @@ class ScoverageAggregate extends DefaultTask {
5261

5362
if (coverage.nonEmpty()) {
5463
new ScoverageWriter(project.logger).write(
55-
project.projectDir,
64+
sources.get().getFiles(),
5665
reportDir.get(),
5766
coverage.get(),
5867
sourceEncoding.get(),

0 commit comments

Comments
 (0)