Created
February 27, 2013 05:15
-
-
Save ben-manes/5045293 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply from: "${rootDir}/coverage.gradle" | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath "org.ajoberstar:gradle-jacoco:0.1.0" | |
} | |
} | |
task wrapper(type: Wrapper, description: "Generates the gradle wrapper") { | |
gradleVersion = "1.4" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: "java" | |
apply plugin: "jacoco" | |
import org.ajoberstar.gradle.jacoco.tasks.* | |
task coverageReport(type: JacocoReport) { | |
// can include one or more execution files | |
executionData = files(test.jacoco.destFile) | |
// must specify the classes that you want coverage data for | |
classFiles = sourceSets.main.output | |
// provide the source files that go along with those classes | |
sourceFiles = sourceSets.main.allSource | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gradle build | |
FAILURE: Build failed with an exception. | |
* Where: | |
Script '/Users/bmanes/projects/jacoco/coverage.gradle' line: 6 | |
* What went wrong: | |
A problem occurred evaluating script. | |
> Could not find property 'JacocoReport' on root project 'jocaco'. | |
* Try: | |
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. | |
BUILD FAILED | |
Total time: 1.473 secs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you change your
coverage.gradle
to the following it should work. It's not ideal, but there's some goofiness with how Gradle handles the classpath of applied scripts. An applied script can't reference classes from thebuild.gradle
's classpath, butapply plugin: 'somestring'
does seem to end up using it. Without declaring the buildscript dependency in both files, you need to reference the class name of the plugin.buildscript { repositories { mavenCentral() } dependencies { classpath "org.ajoberstar:gradle-jacoco:0.1.0" } }
import org.ajoberstar.gradle.jacoco.tasks.*
import org.ajoberstar.gradle.jacoco.plugins.*
apply plugin: "java"
apply plugin: JacocoPlugin
task coverageReport(type: JacocoReport.class) {
// can include one or more execution files
executionData = files(test.jacoco.destFile)
// must specify the classes that you want coverage data for
classFiles = sourceSets.main.output
// provide the source files that go along with those classes
sourceFiles = sourceSets.main.allSource
}