Skip to content

Commit 73bd170

Browse files
committed
#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

+2-2
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

+2-2
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

+2-2
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

+4-4
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

+7-7
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

+7-7
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

+3-3
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

+2-2
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

+3-3
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

+10-1
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(),

src/main/groovy/org/scoverage/ScoverageExtension.groovy

-5
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class ScoverageExtension {
2828
final Property<File> dataDir
2929
/** a directory to write final output to */
3030
final Property<File> reportDir
31-
/** sources to highlight */
32-
final Property<File> sources
3331
/** range positioning for highlighting */
3432
final Property<Boolean> highlighting
3533
/** regex for each excluded package */
@@ -61,9 +59,6 @@ class ScoverageExtension {
6159

6260
scoverageScalaVersion = project.objects.property(String)
6361

64-
sources = project.objects.property(File)
65-
sources.set(project.projectDir)
66-
6762
dataDir = project.objects.property(File)
6863
dataDir.set(new File(project.buildDir, 'scoverage'))
6964

src/main/groovy/org/scoverage/ScoveragePlugin.groovy

+7-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class ScoveragePlugin implements Plugin<PluginAware> {
124124
group = 'verification'
125125
runner = scoverageRunner
126126
reportDir = taskReportDir
127-
sources = extension.sources
127+
sources = originalSourceSet.scala.getSourceDirectories()
128128
dataDir = extension.dataDir
129129
sourceEncoding.set(detectedSourceEncoding)
130130
coverageOutputCobertura = extension.coverageOutputCobertura
@@ -143,6 +143,7 @@ class ScoveragePlugin implements Plugin<PluginAware> {
143143
group = 'verification'
144144
runner = scoverageRunner
145145
reportDir = extension.reportDir
146+
sources = originalSourceSet.scala.getSourceDirectories()
146147
dirsToAggregateFrom = dataDirs
147148
sourceEncoding.set(detectedSourceEncoding)
148149
deleteReportsOnAggregation = false
@@ -299,6 +300,10 @@ class ScoveragePlugin implements Plugin<PluginAware> {
299300
}
300301
}
301302
def allReportTasks = childReportTasks + globalReportTask.get()
303+
def allSources = project.objects.fileCollection()
304+
allReportTasks.each {
305+
allSources = allSources.plus(it.sources.get())
306+
}
302307
def aggregationTask = project.tasks.create(AGGREGATE_NAME, ScoverageAggregate) {
303308
def dataDirs = allReportTasks.findResults { it.dirsToAggregateFrom.get() }.flatten()
304309
onlyIf {
@@ -308,6 +313,7 @@ class ScoveragePlugin implements Plugin<PluginAware> {
308313
group = 'verification'
309314
runner = scoverageRunner
310315
reportDir = extension.reportDir
316+
sources = allSources
311317
sourceEncoding.set(detectedSourceEncoding)
312318
dirsToAggregateFrom = dataDirs
313319
deleteReportsOnAggregation = extension.deleteReportsOnAggregation

src/main/groovy/org/scoverage/ScoverageReport.groovy

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package org.scoverage
22

33
import org.gradle.api.DefaultTask
4+
import org.gradle.api.file.FileCollection
45
import org.gradle.api.provider.Property
56
import org.gradle.api.tasks.CacheableTask
67
import org.gradle.api.tasks.Input
78
import org.gradle.api.tasks.InputDirectory
9+
import org.gradle.api.tasks.InputFiles
810
import org.gradle.api.tasks.Nested
911
import org.gradle.api.tasks.OutputDirectory
1012
import org.gradle.api.tasks.PathSensitive
@@ -23,9 +25,9 @@ class ScoverageReport extends DefaultTask {
2325
@PathSensitive(RELATIVE)
2426
final Property<File> dataDir = project.objects.property(File)
2527

26-
@InputDirectory
28+
@InputFiles
2729
@PathSensitive(RELATIVE)
28-
final Property<File> sources = project.objects.property(File)
30+
final Property<FileCollection> sources = project.objects.property(FileCollection)
2931

3032
@OutputDirectory
3133
final Property<File> reportDir = project.objects.property(File)
@@ -54,7 +56,7 @@ class ScoverageReport extends DefaultTask {
5456
project.logger.info("[scoverage] Could not find coverage file, skipping...")
5557
} else {
5658
new ScoverageWriter(project.logger).write(
57-
sources.get(),
59+
sources.get().getFiles(),
5860
reportDir.get(),
5961
coverage.get(),
6062
sourceEncoding.get(),

0 commit comments

Comments
 (0)