Skip to content
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

Task 'aggregateScoverage' not found in root project #176

Open
mwos-sl opened this issue Nov 19, 2021 · 4 comments
Open

Task 'aggregateScoverage' not found in root project #176

mwos-sl opened this issue Nov 19, 2021 · 4 comments

Comments

@mwos-sl
Copy link

mwos-sl commented Nov 19, 2021

I've got multi-project gradle build. Root build.gradle:

plugins {
  ...
  id "org.scoverage" version "7.0.0" apply false
}

allprojects  {
  ...
  
  apply plugin: "scala"
  apply plugin: 'java-library'
  // NOTE applying also for root project
  apply plugin: "org.scoverage"

  dependencies {
    api("org.scala-lang:scala-library:$scalaMajorVersion.$scalaMinorVersion")
  }

  scoverage {
    scoverageVersion = "1.4.10"
  }
}

When I call

./gradlew dummy:reportScoverage util:reportScoverage aggregateScoverage

I get error:

Task 'aggregateScoverage' not found in root project 'all'.

So even though it seems it should be there (https://github.com/scoverage/gradle-scoverage/blob/master/src/main/groovy/org/scoverage/ScoveragePlugin.groovy#L313), I followed the answers from some other issues (#33, #85 (comment), #66) and added this in the root:

task aggregateScoverage(type: org.scoverage.ScoverageAggregate)

without even defining dependancy yet, and when I rerun the gradlew command I get:

Cannot add task 'aggregateScoverage' as a task with that name already exists.

even though it was claimed to not exist before I added 🤯

Env

scala 2.11.15
gradle 7.2
gradle scoverage plugin 7.0.0
scoverage 1.4.10

@mwos-sl
Copy link
Author

mwos-sl commented Nov 29, 2021

Hmm, but the code seem strange, because inside project.afterEvaluate:
https://github.com/scoverage/gradle-scoverage/blame/master/src/main/groovy/org/scoverage/ScoveragePlugin.groovy#L106

we say project.gradle.projectsEvaluated:
https://github.com/scoverage/gradle-scoverage/blame/master/src/main/groovy/org/scoverage/ScoveragePlugin.groovy#L297

and inside this one aggregateScoverage is declared:
https://github.com/scoverage/gradle-scoverage/blame/master/src/main/groovy/org/scoverage/ScoveragePlugin.groovy#L313

But gradle has no chances to jump into this block, because somewhere between those 2 gradle checks gradle checks if the task which we're calling from the console (aggregateScoverage) exists. And of course it does not yet, so gradle fails as described:

Task 'aggregateScoverage' not found in root project 'all'.

As a result we never go into the clousure defined within project.gradle.projectsEvaluated.

Question: Why project.gradle.projectsEvaluated is needed (https://github.com/scoverage/gradle-scoverage/blame/master/src/main/groovy/org/scoverage/ScoveragePlugin.groovy#L297) in the first place? Isn't the fact that this is inside afterEvaluate enough?

cc @eyalroth I see you were the last one touching this area, so maybe you know?

@mwos-sl
Copy link
Author

mwos-sl commented Nov 29, 2021

Huh, configuration-on-demand changes behaviour of project.gradle.projectsEvaluated.

When I temporarily disabled it:

org.gradle.configureondemand=false

then it enters the scope which creates aggregateScoverage.

I think this very old issue is related:
gradle/gradle#9489
and it doesn't seem it's going to be addressed.

Unfortunately disabling configuration-on-demand isn't a proper fix for us, as we need configuration-on-demand (we've got monorepo with severa hundreds of modules).

@q-benwillis
Copy link

@mwos-sl Did you ever find a solution to this? Currently seeing the same issue when attempting to use the plugin with configuration-on-demand enabled in a mono-repo with a large number of projects.

@wosiu
Copy link

wosiu commented Jun 28, 2023 via email

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

3 participants