Skip to content

testScoverage task's source property is incorrect #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dsilvasc opened this issue Sep 5, 2018 · 3 comments
Closed

testScoverage task's source property is incorrect #78

dsilvasc opened this issue Sep 5, 2018 · 3 comments

Comments

@dsilvasc
Copy link

dsilvasc commented Sep 5, 2018

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"))
      }
    }
  }
}
@maiflai
Copy link
Contributor

maiflai commented Sep 9, 2018

Thanks for pointing this out - please could you test the 2.4.0 release to see if it resolves the issue?

Stu

@dsilvasc
Copy link
Author

This looks fixed in 2.4.0, tested with Gradle 4.10:

> Task :common:concurrent:compileJava NO-SOURCE
> Task :common:concurrent:compileScala FROM-CACHE
> Task :common:concurrent:processResources NO-SOURCE
> Task :common:concurrent:classes UP-TO-DATE
> Task :common:concurrent:jar
> Task :common:concurrent:compileScoverageJava NO-SOURCE
> Task :common:concurrent:compileScoverageScala FROM-CACHE
> Task :common:concurrent:processScoverageResources NO-SOURCE
> Task :common:concurrent:scoverageClasses UP-TO-DATE
> Task :common:concurrent:compileTestJava NO-SOURCE
> Task :common:concurrent:compileTestScala FROM-CACHE
> Task :common:concurrent:processTestResources NO-SOURCE
> Task :common:concurrent:testClasses UP-TO-DATE
> Task :common:concurrent:testScoverage
> Task :common:concurrent:reportScoverage FROM-CACHE
> Task :common:concurrent:checkBranchCoverage
> Task :common:concurrent:checkStatementCoverage
> Task :common:concurrent:checkCoverage
> Task :common:concurrent:checkstyleMain NO-SOURCE
> Task :common:concurrent:checkstyleTest NO-SOURCE
> Task :common:concurrent:scalaStyle
> Task :common:concurrent:assemble
> Task :common:concurrent:snapengineDuplicateFinder
> Task :common:concurrent:test FROM-CACHE
> Task :common:concurrent:check

@maiflai
Copy link
Contributor

maiflai commented Nov 28, 2018

Thanks very much, I'll close the issue then.

@maiflai maiflai closed this as completed Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants