Skip to content

Commit

Permalink
remove the unnecessary compilation of test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
maiflai committed Sep 9, 2018
1 parent 5cd2fe5 commit f70b696
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
26 changes: 7 additions & 19 deletions src/main/groovy/org/scoverage/ScoverageExtension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ScoverageExtension {
description = 'Scoverage dependencies'
}

def mainSourceSet = project.sourceSets.create('scoverage') {
def instrumentedSourceSet = project.sourceSets.create('scoverage') {
def original = project.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)

resources.source(original.resources)
Expand All @@ -65,35 +65,23 @@ class ScoverageExtension {
runtimeClasspath = it.output + project.configurations.scoverage + original.runtimeClasspath
}

def testSourceSet = project.sourceSets.create('testScoverage') {
def original = project.sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME)

java.source(original.java)
resources.source(original.resources)
scala.source(original.scala)

compileClasspath = mainSourceSet.output + original.compileClasspath
runtimeClasspath = it.output + mainSourceSet.output + project.configurations.scoverage + original.runtimeClasspath
}

def scoverageJar = project.tasks.create('jarScoverage', Jar.class) {
dependsOn('scoverageClasses')
classifier = ScoveragePlugin.CONFIGURATION_NAME
from mainSourceSet.output
from instrumentedSourceSet.output
}
project.artifacts {
scoverage scoverageJar
}

project.tasks.create(ScoveragePlugin.TEST_NAME, Test.class) {
conventionMapping.map("testClassesDir", new Callable<Object>() {
Object call() throws Exception {
return testSourceSet.output.classesDir
}
})
conventionMapping.map("classpath", new Callable<Object>() {
Object call() throws Exception {
return testSourceSet.runtimeClasspath
def testSourceSet = project.sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME)
return testSourceSet.output +
instrumentedSourceSet.output +
project.configurations.scoverage +
testSourceSet.runtimeClasspath
}
})
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/groovy/org/scoverage/ScoveragePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class ScoveragePlugin implements Plugin<Project> {
static String REPORT_NAME = 'reportScoverage'
static String CHECK_NAME = 'checkScoverage'
static String COMPILE_NAME = 'compileScoverageScala'
static String COMPILE_TEST_NAME = 'compileTestScoverageScala'

@Override
void apply(Project t) {
Expand All @@ -20,6 +19,6 @@ class ScoveragePlugin implements Plugin<Project> {
}

protected static ScoverageExtension extensionIn(Project project) {
project.extensions[CONFIGURATION_NAME]
project.extensions[CONFIGURATION_NAME] as ScoverageExtension
}
}

0 comments on commit f70b696

Please sign in to comment.