I have a custom task in Gradle (2.3)
task myCustomTask (dependsOn: [ jacocoTestReport ]) << {
//Adding this didn't work, gives an error that options is not a property.
//options.compilerArgs = ["-x compileJava -x classes -x test -x testClasses"]
//Seems like the following line actually works!!! but still errors for "options" property. Strange!!
//myCustomTask.options = [ "-x compileJava -x classes -x test -x testClasses" ]
//..
//...some...operation
//..
}
How can I change the above custom task code in Gradle so that it can do what I'm doing at command line. I want that when someone calls myCustomTask and if it depends upon any of the Gradle's core tasks (like compileJava, classes etc), then it should not call those tasks (i.e. to mimic -x someTask behavior at command line).
The following works!!
$ gradle jacocoTestReport -x compileJava -x classes -x test -x testClasses
Then, what I want is: Running gradle myCustomTask should do the same (what the above command at command line is doing).
Error:
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jacocoTestReport
:myCustomTask FAILED
FAILURE: Build failed with an exception.
* Where:
Initialization script '/home/giga/gradle-2.3/init.d/extra1.common-thids.gradle' line: 450
* What went wrong:
Execution failed for task ':myCustomTask'.
> No such property: options for class: org.gradle.api.DefaultTask_Decorated
Possible solutions: actions
cat -n on extra1..gradle file (init.d level file):
449 task myCustomTask (dependsOn: [ jacocoTestReport ]) << {
450 myCustomTask.options = [ " -x compileJava -x classes -x test -x testClasses " ]
451 }