Closed
Description
In a multi-module project, defining the aggregation task must be made in the build.gradle
and cannot be extracted to a separate script file.
The following configuration:
build.gradle
:
plugins {
id "org.scoverage" version "2.5.0" apply false
}
apply from: new File(rootProject.projectDir, "gradle/scoverage.gradle")
gradle/scoverage.gradle
:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
// necessary for resolving 'org.scoverage.ScoverageAggregate'
classpath group: 'gradle.plugin.org.scoverage', name: 'gradle-scoverage', version: '2.5.0'
}
}
task aggregateScoverage(type: org.scoverage.ScoverageAggregate)
Will cause this exception upon execution of aggregateScoverage
:
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'org.scoverage.ScoverageExtension_Decorated@70bf1425' with class 'org.scoverage.ScoverageExtension_Decorated' to class 'org.scoverage.ScoverageExtension'
at org.scoverage.ScoveragePlugin.extensionIn(ScoveragePlugin.groovy:22)
at org.scoverage.ScoverageAggregate.exec(ScoverageAggregate.groovy:12)
There are two problems here:
- The incorrect reading of properties from within tasks.
ScoveragePlugin#extensionIn
is not the correct way of reading configuration from the extension. See Gradle's official guide on how to map extension properties to task properties. - Users shouldn't be bothered with defining the aggregation task on their own, which requires the entire
buildscript
section unless the definition is in the mainbuild.gradle
file. The task should be defined by default upon applying the plugin, much like the other tasks.
Metadata
Metadata
Assignees
Labels
No labels