Skip to content

Commit 6849ddf

Browse files
authored
Merge pull request #192 from scoverage/scoverage2
Scoverage2
2 parents 3021528 + 32d2564 commit 6849ddf

File tree

23 files changed

+291
-204
lines changed

23 files changed

+291
-204
lines changed

Diff for: README.md

+5-12
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,17 @@ scoverage {
105105
}
106106
```
107107

108-
### Run without normal compilation
109-
110-
By default, running any of the plugin tasks will compile the code both using "normal" compilation (`compileScala`)
111-
and using the scoverage scalac plugin (`compileScoverageScala`).
112-
113-
In cases where you only wish to generate reports / validate coverage, but are not interested in publishing the code,
114-
it is possible to only compile the code with the scoverage scalac plugin, thus reducing build times significantly.
115-
In order to do so, simply add the arguments `-PscoverageCompileOnly` to the gradle execution.
116-
For example: `gradle reportScoverage -PscoverageCompileOnly`.
117-
118-
Note that this mode is incompatible with parallel builds in multi-module projects.
119-
120108
### Compatibility with Consistent Versions Plugin
121109

122110
In order for the plugin to work alongside [Palantir's consistent versions plugin](https://github.com/palantir/gradle-consistent-versions),
123111
the Scala version must be manually configured (via `scoverageScalaVersion`); otherwise, the plugin will attempt to
124112
resolve the compilation classpath, which is prohibited by the versions plugin.
125113

114+
Migration to 8.x
115+
----------------
116+
117+
* Running without normal compilation is no longer supported.
118+
126119
Migration to 7.x
127120
----------------
128121

Diff for: build.gradle

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java-gradle-plugin'
3-
id "com.gradle.plugin-publish" version "1.0.0"
3+
id "com.gradle.plugin-publish" version "1.1.0"
44
id "org.jetbrains.gradle.plugin.idea-ext" version "1.0"
55
}
66

@@ -11,7 +11,7 @@ repositories {
1111
group 'org.scoverage'
1212
description = 'gradle-scoverage is a Gradle plugin for calculating code coverage using Scoverage'
1313
if (project.version == 'unspecified') {
14-
version = '7.0.0-SNAPSHOT'
14+
version = '8.0.0-SNAPSHOT'
1515
}
1616
ext {
1717
website = 'http://scoverage.org'
@@ -22,22 +22,19 @@ ext {
2222
}
2323

2424
gradlePlugin {
25+
website = project.ext.website
26+
vcsUrl = project.ext.vcsUrl
27+
description = project.description
2528
plugins {
2629
gradleScoverage {
2730
id = 'org.scoverage'
2831
implementationClass = 'org.scoverage.ScoveragePlugin'
2932
displayName = 'Gradle Scoverage plugin'
33+
tags.set(['coverage', 'scala', 'scoverage'])
3034
}
3135
}
3236
}
3337

34-
pluginBundle {
35-
website = project.website
36-
vcsUrl = ext.vcsUrl
37-
description = project.description
38-
tags = ['coverage', 'scala', 'scoverage']
39-
}
40-
4138
apply plugin: 'maven-publish'
4239
apply plugin: 'groovy'
4340

@@ -46,7 +43,8 @@ targetCompatibility = '1.8'
4643

4744

4845
dependencies {
49-
compileOnly "org.scoverage:scalac-scoverage-plugin_2.13:1.4.2"
46+
compileOnly "org.scoverage:scalac-scoverage-plugin_2.13.8:2.0.7"
47+
compileOnly "org.scoverage:scalac-scoverage-reporter_2.13:2.0.7"
5048
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
5149

5250
testImplementation 'junit:junit:4.12'
@@ -116,7 +114,7 @@ gradlePlugin {
116114

117115
task groovydocJar(type: Jar, dependsOn: groovydoc) {
118116
from "$buildDir/docs/groovydoc"
119-
classifier 'groovydoc'
117+
archiveClassifier.set('groovydoc')
120118
}
121119

122120
def propOrDefault(String property) {

Diff for: gradle/wrapper/gradle-wrapper.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
distributionSha256Sum=e111cb9948407e26351227dabce49822fb88c37ee72f1d1582a69c68af2e702f
45
zipStoreBase=GRADLE_USER_HOME
56
zipStorePath=wrapper/dists
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package org.scoverage;
2+
3+
public class Scala32Test extends ScalaVersionTest {
4+
5+
public Scala32Test() { super("3_2"); }
6+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dependencies {
2-
implementation group: 'org.scala-lang', name: 'scala-library', version: "2.12.8"
2+
implementation group: 'org.scala-lang', name: 'scala-library', version: "2.12.17"
33
testImplementation group: 'org.scalatest', name: "scalatest_2.12", version: scalatestVersion
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
dependencies {
2-
implementation group: 'org.scala-lang', name: 'scala-library', version: "2.13.1"
2+
implementation group: 'org.scala-lang', name: 'scala-library', version: "2.13.10"
33
testImplementation group: 'org.scalatest', name: "scalatest_2.13", version: scalatestVersion
44
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies {
2+
implementation 'org.scala-lang:scala3-library_3:3.2.0'
3+
testImplementation 'org.scalatest:scalatest_3:3.2.14'
4+
testImplementation "org.scalatestplus:junit-4-13_3:3.2.14.0"
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.hello
2+
3+
class World3_2 {
4+
5+
// Scala 3 enum to force Scala 3 (Dotty) compiler
6+
enum Num(val value: String):
7+
case Three extends Num("3")
8+
case Two extends Num("2")
9+
10+
def foo(): String = {
11+
val s = Num.Three.value + Num.Two.value
12+
s
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.hello
2+
3+
import org.junit.runner.RunWith
4+
import org.scalatest.funsuite.AnyFunSuite
5+
import org.scalatestplus.junit.JUnitRunner
6+
7+
@RunWith(classOf[JUnitRunner])
8+
class World3_2Suite extends AnyFunSuite {
9+
10+
test("foo") {
11+
new World3_2().foo()
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include '2_12', '2_13'
1+
include '2_12', '2_13', '3_2'

Diff for: src/functionalTest/java/org/scoverage/ScalaMultiModuleTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67
import java.io.File;
@@ -60,6 +61,7 @@ public void reportScoverageOnlyA() {
6061
}
6162

6263
@Test
64+
@Ignore
6365
public void reportScoverageOnlyAWithoutNormalCompilation() {
6466

6567
AssertableBuildResult result = run("clean", ":a:" + ScoveragePlugin.getREPORT_NAME(),
@@ -192,6 +194,7 @@ public void checkScoverageWithoutCoverageInA() throws Exception {
192194
}
193195

194196
@Test
197+
@Ignore
195198
public void checkScoverageWithoutNormalCompilationAndWithoutCoverageInCommon() throws Exception {
196199

197200
AssertableBuildResult result = runAndFail("clean",
@@ -254,6 +257,7 @@ public void checkAndAggregateScoverageWithoutCoverageInAll() throws Exception {
254257
}
255258

256259
@Test
260+
@Ignore
257261
public void aggregateScoverageWithoutNormalCompilation() throws Exception {
258262

259263
AssertableBuildResult result = run("clean", ScoveragePlugin.getAGGREGATE_NAME(),

Diff for: src/functionalTest/java/org/scoverage/ScalaMultiModuleWithMultipleTestTasksTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67

@@ -188,6 +189,7 @@ public void checkScoverageWithoutCoverageInA() throws Exception {
188189
}
189190

190191
@Test
192+
@Ignore
191193
public void checkScoverageWithoutNormalCompilationAndWithoutCoverageInCommon() throws Exception {
192194

193195
AssertableBuildResult result = runAndFail("clean",
@@ -251,6 +253,7 @@ public void checkAndAggregateScoverageWithoutCoverageInAll() throws Exception {
251253
}
252254

253255
@Test
256+
@Ignore
254257
public void aggregateScoverageWithoutNormalCompilation() throws Exception {
255258

256259
AssertableBuildResult result = run("clean", ScoveragePlugin.getAGGREGATE_NAME(),

Diff for: src/functionalTest/java/org/scoverage/ScalaSingleModuleTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67
public class ScalaSingleModuleTest extends ScoverageFunctionalTest {
@@ -100,6 +101,7 @@ public void reportScoverageWithExcludedClasses() throws Exception {
100101
}
101102

102103
@Test
104+
@Ignore
103105
public void reportScoverageWithoutNormalCompilation() throws Exception {
104106

105107
AssertableBuildResult result = run("clean", ScoveragePlugin.getREPORT_NAME(),

Diff for: src/functionalTest/java/org/scoverage/ScalaSingleModuleWithMultipleTestTasksTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67
public class ScalaSingleModuleWithMultipleTestTasksTest extends ScoverageFunctionalTest {
@@ -118,6 +119,7 @@ public void reportScoverageWithExcludedClasses() throws Exception {
118119
}
119120

120121
@Test
122+
@Ignore
121123
public void reportScoverageWithoutNormalCompilation() throws Exception {
122124

123125
AssertableBuildResult result = run("clean", ScoveragePlugin.getREPORT_NAME(),

Diff for: src/functionalTest/java/org/scoverage/ScoverageFunctionalTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ private void configureArguments(String... arguments) {
122122
List<String> fullArguments = new ArrayList<>();
123123

124124
fullArguments.add("-PscalaVersionMajor=2");
125-
fullArguments.add("-PscalaVersionMinor=12");
126-
fullArguments.add("-PscalaVersionBuild=8");
125+
fullArguments.add("-PscalaVersionMinor=13");
126+
fullArguments.add("-PscalaVersionBuild=10");
127127
fullArguments.add("-PjunitVersion=5.3.2");
128128
fullArguments.add("-PjunitPlatformVersion=1.3.2");
129129
fullArguments.add("-PscalatestVersion=3.0.8");

Diff for: src/functionalTest/resources/projects/scala-multi-module-multiple-test-tasks/build.gradle

+26-27
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,35 @@ allprojects {
2525
testImplementation group: 'org.scalatest', name: "scalatest_${scalaVersionMajor}.${scalaVersionMinor}", version: scalatestVersion
2626
}
2727

28-
test {
29-
useJUnitPlatform()
30-
maxParallelForks = 1
31-
}
32-
33-
configurations {
34-
intTestImplementation.extendsFrom testImplementation
35-
intTestRuntimeOnly.extendsFrom testRuntimeOnly
36-
}
37-
sourceSets {
38-
intTest {
39-
resources.srcDir file('src/intTest/resources')
40-
scala {
41-
compileClasspath += main.output + test.output
42-
runtimeClasspath += main.output + test.output
43-
srcDir file("${projectDir}/src/intTest/scala")
28+
testing {
29+
suites {
30+
configureEach {
31+
useJUnit()
32+
targets.configureEach {
33+
testTask.configure {
34+
maxParallelForks = 1
35+
}
36+
}
37+
}
38+
intTest(JvmTestSuite) {
39+
testType = TestSuiteType.INTEGRATION_TEST
40+
// dependencies { ... } does not appear to work as advertised?
41+
sources {
42+
scala {
43+
compileClasspath += sourceSets.test.compileClasspath + sourceSets.main.output + sourceSets.test.output
44+
runtimeClasspath += sourceSets.test.runtimeClasspath
45+
}
46+
}
47+
targets.configureEach {
48+
testTask.configure{
49+
outputs.upToDateWhen { false }
50+
mustRunAfter(test)
51+
}
52+
}
4453
}
4554
}
4655
}
47-
48-
49-
task intTest(type: Test) {
50-
testClassesDirs = sourceSets.intTest.output.classesDirs
51-
classpath = sourceSets.intTest.runtimeClasspath
52-
outputs.upToDateWhen { false }
53-
54-
maxParallelForks = 1
55-
}
56-
check.dependsOn(intTest)
57-
intTest.mustRunAfter(test)
56+
check.dependsOn(testing.suites.intTest)
5857

5958
scoverage {
6059
minimumRate = 0.5

Diff for: src/functionalTest/resources/projects/scala-single-module-multiple-test-tasks/build.gradle

+27-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'io.spring.dependency-management' version "1.0.4.RELEASE"
33
id 'org.scoverage'
4+
id 'jvm-test-suite'
45
}
56

67
repositories {
@@ -27,39 +28,35 @@ dependencies {
2728
testImplementation group: 'org.scalatest', name: "scalatest_${scalaVersionMajor}.${scalaVersionMinor}", version: scalatestVersion
2829
}
2930

30-
test {
31-
useJUnitPlatform()
32-
}
33-
34-
35-
configurations {
36-
intTestImplementation.extendsFrom testImplementation
37-
intTestRuntimeOnly.extendsFrom testRuntimeOnly
38-
}
39-
sourceSets {
40-
intTest {
41-
resources.srcDir file('src/intTest/resources')
42-
scala {
43-
compileClasspath += main.output + test.output
44-
runtimeClasspath += main.output + test.output
45-
srcDir file("${projectDir}/src/intTest/scala")
31+
testing {
32+
suites {
33+
configureEach {
34+
useJUnit()
35+
targets.configureEach {
36+
testTask.configure {
37+
maxParallelForks = 1
38+
}
39+
}
40+
}
41+
intTest(JvmTestSuite) {
42+
testType = TestSuiteType.INTEGRATION_TEST
43+
// dependencies { ... } does not appear to work as advertised?
44+
sources {
45+
scala {
46+
compileClasspath += sourceSets.test.compileClasspath + sourceSets.main.output + sourceSets.test.output
47+
runtimeClasspath += sourceSets.test.runtimeClasspath
48+
}
49+
}
50+
targets.configureEach {
51+
testTask.configure{
52+
outputs.upToDateWhen { false }
53+
mustRunAfter(test)
54+
}
55+
}
4656
}
4757
}
4858
}
49-
50-
test {
51-
maxParallelForks = 1
52-
}
53-
54-
task intTest(type: Test) {
55-
testClassesDirs = sourceSets.intTest.output.classesDirs
56-
classpath = sourceSets.intTest.runtimeClasspath
57-
outputs.upToDateWhen { false }
58-
59-
maxParallelForks = 1
60-
}
61-
check.dependsOn(intTest)
62-
intTest.mustRunAfter(test)
59+
check.dependsOn(testing.suites.intTest)
6360

6461
scoverage {
6562
minimumRate = 0.6

0 commit comments

Comments
 (0)