Closed
Description
The testScoverage task gets skipped with "NO-SOURCE" if you skip the compileTestScala task.
People might want to skip the compileTestScala and test tasks when they're already running compileTestScoverageScala and testScoverage, to avoid compiling and running tests twice.
I'm using this as a workaround for now:
// the testScoverage task already runs all the tests;
// no need to run them twice
// https://stackoverflow.com/questions/30512237/configuring-a-gradle-task-based-on-task-to-be-executed
gradle.taskGraph.whenReady {
val test by tasks
val compileTestScala by tasks
val compileTestScoverageScala by tasks
if (hasTask(testScoverage)) {
test.enabled = false
}
if (hasTask(compileTestScoverageScala)) {
compileTestScala.enabled = false
// Since we won't run compileTestScala, change the test source set's output
// to the output dir of compileTestScoverageScala.
// Otherwise the task testScoverage will be skipped with "NO-SOURCE".
val testSourceSet = project.the<JavaPluginConvention>().sourceSets.getByName("test")
// need to use withGroovyBuilder because of this issue:
// // https://github.com/gradle/kotlin-dsl/issues/650
testSourceSet.withGroovyBuilder {
"scala" {
"setOutputDir"(project.file("${project.buildDir}/classes/scala/testScoverage"))
}
}
}
}
Metadata
Metadata
Assignees
Labels
No labels