Skip to content

Commit 48c86db

Browse files
committed
Merge remote-tracking branch 'remotes/eyalroth/issues/121/java-platform-compatibility'
2 parents 780dad5 + 7c003ce commit 48c86db

File tree

22 files changed

+235
-70
lines changed

22 files changed

+235
-70
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ You can find instructions on how to apply the plugin at: http://plugins.gradle.
2323
When applied on a project with sub-projects, the plugin will create the aggregation task `aggregateScoverage`, which
2424
will first generate reports for each project individually (including the parent project), and will then generate an
2525
aggregated result based on these reports.
26+
27+
The plugin must be applied on a sub-project for it to be included in the aggregated; applying the plugin on a
28+
project _does not_ automatically apply it on sub-projects.
2629

2730
The aggregated report will override the parent-project specific report (`parent-project/build/reports/scoverage`).
2831

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.scoverage;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
public class MultiModulePluginNotConfiguredForScalaTest extends ScoverageFunctionalTest {
7+
8+
public MultiModulePluginNotConfiguredForScalaTest() {
9+
super("multi-module-plugin-not-configured-for-scala");
10+
}
11+
12+
@Test
13+
public void checkAndAggregateScoverage() throws Exception {
14+
15+
AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME(),
16+
ScoveragePlugin.getAGGREGATE_NAME());
17+
18+
result.assertTaskSkipped(ScoveragePlugin.getREPORT_NAME());
19+
result.assertTaskSkipped("scala_only:" + ScoveragePlugin.getREPORT_NAME());
20+
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getREPORT_NAME());
21+
result.assertTaskSkipped(ScoveragePlugin.getCHECK_NAME());
22+
result.assertTaskSkipped("scala_only:" + ScoveragePlugin.getCHECK_NAME());
23+
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCHECK_NAME());
24+
result.assertTaskSkipped(ScoveragePlugin.getAGGREGATE_NAME());
25+
26+
assertReportDirsEmpty();
27+
28+
Assert.assertTrue(result.getResult().getOutput().contains("Scala sub-project 'scala_only' doesn't have Scoverage applied"));
29+
Assert.assertFalse(result.getResult().getOutput().contains("Scala sub-project 'java_only' doesn't have Scoverage applied"));
30+
}
31+
32+
private void assertReportDirsEmpty() {
33+
34+
Assert.assertFalse(reportDir().exists());
35+
Assert.assertFalse(reportDir(projectDir().toPath().resolve("scala_only").toFile()).exists());
36+
Assert.assertFalse(reportDir(projectDir().toPath().resolve("java_only").toFile()).exists());
37+
}
38+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ public void checkAndAggregateScoverage() throws Exception {
1818
AssertableBuildResult result = run("clean", ScoveragePlugin.getCHECK_NAME(),
1919
ScoveragePlugin.getAGGREGATE_NAME());
2020

21-
result.assertTaskOutcome("java_only:" + ScoveragePlugin.getCOMPILE_NAME(), TaskOutcome.NO_SOURCE);
21+
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCOMPILE_NAME());
2222

2323
result.assertTaskSkipped(ScoveragePlugin.getREPORT_NAME());
2424
result.assertTaskSucceeded("scala_only:" + ScoveragePlugin.getREPORT_NAME());
2525
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.getREPORT_NAME());
2626
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getREPORT_NAME());
27+
2728
result.assertTaskSucceeded(ScoveragePlugin.getCHECK_NAME());
2829
result.assertTaskSucceeded("scala_only:" + ScoveragePlugin.getCHECK_NAME());
2930
result.assertTaskSucceeded("mixed_scala_java:" + ScoveragePlugin.getCHECK_NAME());
3031
result.assertTaskSkipped("java_only:" + ScoveragePlugin.getCHECK_NAME());
32+
3133
result.assertTaskSucceeded(ScoveragePlugin.getAGGREGATE_NAME());
3234

3335
assertAllReportFilesExist();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
plugins {
2+
id 'org.scoverage' apply false
3+
}
4+
5+
description = 'a multi-module Scala and Java project that defines scoverage only on root but not on subprojects'
6+
7+
allprojects {
8+
repositories {
9+
jcenter()
10+
}
11+
}
12+
13+
subprojects { p ->
14+
if (p.name != 'dependencies') {
15+
apply plugin: 'java'
16+
dependencies {
17+
implementation platform(project(':dependencies'))
18+
testCompile group: 'org.junit.platform', name: 'junit-platform-runner'
19+
}
20+
21+
test {
22+
useJUnitPlatform()
23+
}
24+
}
25+
}
26+
27+
apply plugin: 'org.scoverage'
28+
scoverage {
29+
minimumRate = 0.5
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
plugins {
2+
id 'java-platform'
3+
}
4+
5+
dependencies {
6+
constraints {
7+
api group: 'org.scala-lang', name: 'scala-library', version: "${scalaVersionMajor}.${scalaVersionMinor}.${scalaVersionBuild}"
8+
9+
api group: 'org.junit.vintage', name: 'junit-vintage-engine', version: junitVersion
10+
api group: 'org.junit.platform', name: 'junit-platform-runner', version: junitPlatformVersion
11+
12+
api group: 'org.scalatest', name: "scalatest_${scalaVersionMajor}.${scalaVersionMinor}", version: scalatestVersion
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies {
2+
testRuntime group: 'org.junit.vintage', name: 'junit-vintage-engine'
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.hello;
2+
3+
public class WorldJavaOnly {
4+
5+
public String foo() {
6+
String s = "java_only" + "a";
7+
return s;
8+
}
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.hello;
2+
3+
import org.junit.Test;
4+
5+
public class WorldJavaOnlyTest {
6+
7+
@Test
8+
public void foo() {
9+
new WorldJavaOnly().foo();
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apply plugin: 'scala'
2+
// apply plugin: 'org.scoverage' // Oops forgot to configure scoverage
3+
4+
dependencies {
5+
compile group: 'org.scala-lang', name: 'scala-library'
6+
7+
testRuntime group: 'org.junit.vintage', name: 'junit-vintage-engine'
8+
testCompile group: 'org.scalatest', name: "scalatest_${scalaVersionMajor}.${scalaVersionMinor}"
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.hello
2+
3+
class WorldScalaOnly {
4+
5+
def foo(): String = {
6+
val s = "scala_only" + "a"
7+
s
8+
}
9+
}

0 commit comments

Comments
 (0)