Skip to content

Commit 80f74b3

Browse files
authored
Merge pull request #155 from helfper/fix-scoverage-version
Use Scala full version in plugin and binary version in runtime
2 parents e6133c0 + 0d5cb3b commit 80f74b3

File tree

5 files changed

+20
-23
lines changed

5 files changed

+20
-23
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ You can find instructions on how to apply the plugin at http://plugins.gradle.or
4343
The plugin exposes multiple options that can be configured by setting them in an `scoverage` block within the project's
4444
build script. These options are as follows:
4545

46-
* `scoverageVersion = <String>` (default `"1.4.2`): The version of the scoverage scalac plugin. This (gradle) plugin
46+
* `scoverageVersion = <String>` (default `"1.4.8`): The version of the scoverage scalac plugin. This (gradle) plugin
4747
should be compatible with all 1+ versions.
4848

4949
* `scoverageScalaVersion = <String>` (default `detected`): The scala version of the scoverage scalac plugin. This

Diff for: build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies {
5353
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.5.2'
5454
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.5.2'
5555

56-
testImplementation 'org.hamcrest:hamcrest-library:1.3'
56+
testImplementation 'org.hamcrest:hamcrest:2.2'
5757
}
5858

5959
sourceSets {

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

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
package org.scoverage;
22

3-
import org.junit.Assert;
43
import org.junit.Test;
54
import org.junit.runner.RunWith;
65
import org.junit.runners.Parameterized;
76

87
import java.util.Arrays;
98
import java.util.Collection;
10-
import java.util.List;
119
import java.util.stream.Stream;
1210

11+
import static org.hamcrest.MatcherAssert.assertThat;
12+
import static org.hamcrest.Matchers.containsString;
13+
import static org.hamcrest.Matchers.stringContainsInOrder;
14+
1315
@RunWith(Parameterized.class)
1416
public class DetectScalaLibraryTest extends ScoverageFunctionalTest {
1517

16-
private static final String SCALA_VERSION = "2.12";
18+
private static final String SCALA_VERSION = "2.13";
1719
private static final String SCALA_LIBRARY_PARAMETER = "-PdetectedScalaLibraryVersion=";
1820

19-
private static final String EXPECTED_OUTPUT_CONFIGURED_VERSION = "Using configured Scala version";
20-
private static final String EXPECTED_OUTPUT_DETECTED_VERSION = "Detected scala library in compilation classpath";
21-
private static final String EXPECTED_OUTPUT_USING = "Using scoverage scalac plugin version '" + SCALA_VERSION;
22-
2321
@Parameterized.Parameter(0)
2422
public String projectDir;
2523

@@ -57,7 +55,7 @@ public void test() {
5755
}
5856
}
5957

60-
private void testWithParameter(String parameter, Boolean detect) {
58+
private void testWithParameter(String parameter, boolean detect) {
6159

6260
String[] basicParameters = {"clean", parameter, "--info"};
6361
String[] parameters = Stream.concat(Arrays.stream(basicParameters), Arrays.stream(additionalParameters))
@@ -66,11 +64,11 @@ private void testWithParameter(String parameter, Boolean detect) {
6664

6765
String output = result.getResult().getOutput();
6866
if (detect) {
69-
Assert.assertTrue(output.contains(EXPECTED_OUTPUT_DETECTED_VERSION));
67+
assertThat(output, containsString("Detected scala library in compilation classpath"));
7068
} else {
71-
Assert.assertTrue(output.contains(EXPECTED_OUTPUT_CONFIGURED_VERSION));
69+
assertThat(output, containsString("Using configured Scala version"));
7270
}
73-
Assert.assertTrue(output.contains(EXPECTED_OUTPUT_USING));
71+
assertThat(output, stringContainsInOrder("Using scoverage scalac plugin", "for scala", SCALA_VERSION));
7472
}
7573

76-
}
74+
}

Diff for: src/main/groovy/org/scoverage/ScoverageExtension.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ScoverageExtension {
5757
project.plugins.apply(ScalaPlugin.class)
5858

5959
scoverageVersion = project.objects.property(String)
60-
scoverageVersion.set('1.4.2')
60+
scoverageVersion.set('1.4.8')
6161

6262
scoverageScalaVersion = project.objects.property(String)
6363

Diff for: src/main/groovy/org/scoverage/ScoveragePlugin.groovy

+7-8
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ScoveragePlugin implements Plugin<PluginAware> {
2424
static final String CHECK_NAME = 'checkScoverage'
2525
static final String COMPILE_NAME = 'compileScoverageScala'
2626
static final String AGGREGATE_NAME = 'aggregateScoverage'
27-
static final String DEFAULT_SCALA_VERSION = '2.12'
27+
static final String DEFAULT_SCALA_VERSION = '2.13.6'
2828

2929
static final String DEFAULT_REPORT_DIR = 'reports' + File.separatorChar + 'scoverage'
3030

@@ -60,15 +60,15 @@ class ScoveragePlugin implements Plugin<PluginAware> {
6060
}
6161

6262
project.afterEvaluate {
63-
def scalaVersion = resolveScalaVersion(project)
63+
def scalaFullVersion = resolveScalaVersion(project)
64+
def scalaBinaryVersion = scalaFullVersion.substring(0, scalaFullVersion.lastIndexOf('.'))
6465
def scoverageVersion = project.extensions.scoverage.scoverageVersion.get()
65-
def fullScoverageVersion = "$scalaVersion:$scoverageVersion"
6666

67-
project.logger.info("Using scoverage scalac plugin version '$fullScoverageVersion'")
67+
project.logger.info("Using scoverage scalac plugin $scoverageVersion for scala $scalaFullVersion")
6868

6969
project.dependencies {
70-
scoverage("org.scoverage:scalac-scoverage-plugin_$fullScoverageVersion")
71-
scoverage("org.scoverage:scalac-scoverage-runtime_$fullScoverageVersion")
70+
scoverage("org.scoverage:scalac-scoverage-plugin_$scalaFullVersion:$scoverageVersion")
71+
scoverage("org.scoverage:scalac-scoverage-runtime_$scalaBinaryVersion:$scoverageVersion")
7272
}
7373
}
7474
}
@@ -360,8 +360,7 @@ class ScoveragePlugin implements Plugin<PluginAware> {
360360
it.moduleVersion.group == "org.scala-lang" && it.moduleVersion.name == "scala-library"
361361
}
362362
if (scalaLibrary != null) {
363-
def fullScalaVersion = scalaLibrary.moduleVersion.version
364-
def scalaVersion = fullScalaVersion.substring(0, fullScalaVersion.lastIndexOf("."))
363+
def scalaVersion = scalaLibrary.moduleVersion.version
365364
project.logger.info("Detected scala library in compilation classpath. Scala version: $scalaVersion")
366365
return scalaVersion
367366
} else {

0 commit comments

Comments
 (0)