I don\'t know if I\'m not doing this right or if i have to handle builtin gradle tasks differently but i have a test task that i defined like this
task testN
I found a workaround to do this. In my scenario I have a task that reads an user input and depending on his anwser I need to create a EAR with different configurations. I used a task of type GradleBuild. Here is the code:
task createEar() << {
def wichTypeOfEar = System.console().readLine("Which EAR?? (a, b)\n")
if(wichTypeOfEar == 'a'){
tasks.earA.execute()
}else{
tasks.earB.execute()
}
}
task earA(type: GradleBuild) {
doFirst{
// Here I can do some stuffs related to ear A
}
tasks = ['ear']
}
task earB(type: GradleBuild) {
doFirst{
// Here I can do some stuffs related to ear B
}
tasks = ['ear']
}
ear {
//Here is the common built in EAR task from 'ear' plugin
}
In you case you could do the following:
task testNGTests(type: Test) {
useTestNG()
}
task testNGTestsWrapper(type: GradleBuild){
tasks = ['testNGTests']
}
task taskA {
doFirst {
testNGTestsWrapper.execute()
}
}
Executing a task from another task isn't (and never was) officially supported. Try to use task dependencies instead, e.g. taskA.dependsOn(testNGTests)
.