Skip to content

Commit 7e17f53

Browse files
committed
Make the check-task flags configurable via the extension and not via the task itself
1 parent ad39e96 commit 7e17f53

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/functionalTest/resources/projects/scala-multi-module/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ allprojects {
2828
useJUnitPlatform()
2929
}
3030

31-
checkScoverage {
31+
scoverage {
3232
minimumRate = 0.5
3333
}
3434
}
3535

36-
checkScoverage {
36+
scoverage {
3737
minimumRate = 0.5
3838
}

src/functionalTest/resources/projects/scala-single-module/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test {
2424
useJUnitPlatform()
2525
}
2626

27-
checkScoverage {
27+
scoverage {
2828
minimumRate = 0.3
2929
}
3030

src/main/groovy/org/scoverage/OverallCheckTask.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ enum CoverageType {
4444
class OverallCheckTask extends DefaultTask {
4545

4646
/** Type of coverage to check. Available options: Line, Statement and Branch */
47-
CoverageType coverageType = CoverageType.Statement
48-
double minimumRate = 0.75
47+
final Property<CoverageType> coverageType = project.objects.property(CoverageType)
48+
final Property<BigDecimal> minimumRate = project.objects.property(BigDecimal)
4949

5050
final Property<File> reportDir = project.objects.property(File)
5151

@@ -56,7 +56,7 @@ class OverallCheckTask extends DefaultTask {
5656
void requireLineCoverage() {
5757
NumberFormat nf = NumberFormat.getInstance(locale == null ? Locale.getDefault() : locale)
5858

59-
Exception failure = checkLineCoverage(nf, reportDir.get(), coverageType, minimumRate)
59+
Exception failure = checkLineCoverage(nf, reportDir.get(), coverageType.get(), minimumRate.get().doubleValue())
6060

6161
if (failure) throw failure
6262
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class ScoverageExtension {
4242

4343
final Property<Boolean> runNormalCompilation
4444

45+
final Property<CoverageType> coverageType
46+
final Property<BigDecimal> minimumRate
47+
4548
ScoverageExtension(Project project) {
4649

4750
project.plugins.apply(JavaPlugin.class)
@@ -88,5 +91,11 @@ class ScoverageExtension {
8891

8992
runNormalCompilation = project.objects.property(Boolean)
9093
runNormalCompilation.set(true)
94+
95+
coverageType = project.objects.property(CoverageType)
96+
coverageType.set(CoverageType.Statement)
97+
98+
minimumRate = project.objects.property(BigDecimal)
99+
minimumRate.set(0.75)
91100
}
92101
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ class ScoveragePlugin implements Plugin<PluginAware> {
120120
project.tasks.create(CHECK_NAME, OverallCheckTask.class) {
121121
dependsOn(reportTask)
122122
group = 'verification'
123+
coverageType = extension.coverageType
124+
minimumRate = extension.minimumRate
123125
reportDir = extension.reportDir
124126
}
125127

0 commit comments

Comments
 (0)