Question

When I run my gradle task test, why are the tasks local, dev, and uat seem to be run as well? I am trying to only run test.

The actual output when I run gradle test is below (see pic). My desired output is below (see pic). What am I doing wrong in my code? I am new to Gradle/Groovy, so my apologies. thanks!

Code: Gradle Code of build.gradle file

Actual Output: Command line output when running

Desired Output: Output I wish I had

Was it helpful?

Solution

When you use

someTask {
    someMethod()
}

then it means to gradle that it must call someMethod() when configuring the task, in the first phase that parses the build script and decides which tasks exist and what depends on what.

To define what must happen when the task is executed, in the second phase, you must use the following syntax:

someTask << {
    someMethod()
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top