Context of my application structure:
- Nothing on root, just settings.gradle and build.gradle with minimal dependency.
- There are many module/subproject, one of them named xyzintegrationtest (xyz is fake example name)
- the integrationtest module xyzintegrationtest has src/main, src/test and src/integrationtest
- The src/main and src/test are empty. src/intgerationtest has integration tests using junit.
- The project xyzintegrationtest has dependency on all projects (implicitly)
- The integrationtest build.gradle file has following task:
task integrationTest(type: Test) {
......
}
Now when I do gradle build (or gradlew build) on root project I expect all projects to compile, and all unit tests to run that are under src/test of each subproject. But it is also calling this integrationTest task, and making integration tests run as well. And more surprisingly it happens sporadically, not consistently. I even tried gradle build -x integrationTest, but it still runs.
So question is:
- Does gradle build run all tasks that are of type test? Then how can I have task that only runs when I invoke it explicitly.
- Is it bug in gradle if first one is not supposed to happen?
- Am I doing something wrong? Structure is pretty flat, all modules/sub-projects at same level, the task name is pretty clear with type:test.
Thanks.
If you have for example the java plugin applied and run the Gradle task test than yes, all test tasks will be executed. Your integrationtest running while specificaly excluding it has probably to do with the Gradle build lifcycle. You might have your code directely in the configuration block rather than in a execution block. So for example:
If no configuration is required you can also do:
This all can be found in the Build Scripting Basics chapter of the Gradle User Guide which is extremely useful if using Gradle.
So if I understand your question and situation correctly this is probably not a bug in Gradle.