Skip to content

Commit cbe754d

Browse files
authored
Merge pull request #137 from JozoVilcek/fix-missing-dependency-compile-task
Do not fail on missing scoverage compile task in dependency
2 parents c5870c9 + e7fc279 commit cbe754d

File tree

9 files changed

+82
-2
lines changed

9 files changed

+82
-2
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.scoverage;
2+
3+
import org.junit.Test;
4+
5+
public class ScalaMultiModuleWithPartialScoverageUseTest extends ScoverageFunctionalTest {
6+
7+
public ScalaMultiModuleWithPartialScoverageUseTest() {
8+
super("scala-multi-module-with-partial-scoverage-use");
9+
}
10+
11+
@Test
12+
public void reportScoverage() {
13+
14+
AssertableBuildResult result = dryRun("clean", ScoveragePlugin.getREPORT_NAME());
15+
16+
result.assertTaskExists(ScoveragePlugin.getREPORT_NAME());
17+
result.assertTaskExists("b:" + ScoveragePlugin.getREPORT_NAME());
18+
}
19+
20+
}

src/functionalTest/resources/projects/scala-multi-module-with-partial-scoverage-use/a/build.gradle

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.hello.a
2+
3+
class WorldA {
4+
5+
def fooA(): String = {
6+
"a"
7+
}
8+
}

src/functionalTest/resources/projects/scala-multi-module-with-partial-scoverage-use/b/build.gradle

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.hello.b
2+
3+
class WorldB {
4+
5+
def fooB(): String = {
6+
"b"
7+
}
8+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
plugins {
2+
id 'org.scoverage' apply false
3+
}
4+
5+
description = 'a multi-module Scala project that builds successfully and has modules which does not use scoverate plugin'
6+
7+
allprojects { p ->
8+
repositories {
9+
jcenter()
10+
}
11+
12+
apply plugin: 'java'
13+
apply plugin: 'scala'
14+
15+
if (p.name != 'a') {
16+
apply plugin: 'org.scoverage'
17+
}
18+
19+
dependencies {
20+
21+
compile group: 'org.scala-lang', name: 'scala-library', version: "${scalaVersionMajor}.${scalaVersionMinor}.${scalaVersionBuild}"
22+
23+
testCompile group: 'org.junit.platform', name: 'junit-platform-runner'
24+
25+
testCompile group: 'org.scalatest', name: "scalatest_${scalaVersionMajor}.${scalaVersionMinor}"
26+
}
27+
}
28+
29+
dependencies {
30+
compile project(':a')
31+
compile project(':b')
32+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include 'a', 'b'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.hello
2+
3+
import org.hello.a.WorldA
4+
import org.hello.a.WorldB
5+
6+
class World {
7+
8+
def foo(): String = {
9+
WorldA.foo() + WorldB.foo()
10+
}
11+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ class ScoveragePlugin implements Plugin<PluginAware> {
161161
it instanceof ScalaCompile
162162
}
163163
originalCompilationDependencies.each {
164-
def dependencyProjectCompileTask = it.project.tasks[COMPILE_NAME]
165-
def dependencyProjectReportTask = it.project.tasks[REPORT_NAME]
164+
def dependencyProjectCompileTask = it.project.tasks.findByName(COMPILE_NAME)
165+
def dependencyProjectReportTask = it.project.tasks.findByName(REPORT_NAME)
166166
if (dependencyProjectCompileTask != null) {
167167
compileTask.dependsOn(dependencyProjectCompileTask)
168168
// we don't want this project's tests to affect the other project's report

0 commit comments

Comments
 (0)