I have a little plugin that creates intTest and accTest in a loop. In both cases, we first need to start a java process in the background and stop it after we’re done.
It’s based on ‘best practices’ from what I could find on stackoverflow and other sources (http://www.slideshare.net/SpringCentral/cd-pipeline-gradlejenkins). The intTest and accTest tasks, however, were always skipped. When gradle was run with ‘-i’ it would report:
:my-server:compileIntTestJava (Thread[main,5,main]) started.
:my-server:compileIntTestJava
Executing task ':my-server:compileIntTestJava' (up-to-date check took 0.061 secs) due to:
Output file /devel/my-project/src/my-server/build/dependency-cache has changed.
Output file /devel/my-project/src/my-server/build/classes/intTest has changed.
Output file /devel/my-project/src/my-server/build/classes/intTest/com/myserver/inttest/SomeIntTest.class has been removed.
All input files are considered out-of-date for incremental task ':my-server:compileIntTestJava'.
Compiling with JDK Java compiler API.
:my-server:compileIntTestJava (Thread[main,5,main]) completed. Took 0.144 secs.
:my-server:processIntTestResources (Thread[main,5,main]) started.
:my-server:processIntTestResources
Skipping task ':my-server:processIntTestResources' as it has no source files.
:my-server:processIntTestResources UP-TO-DATE
:my-server:processIntTestResources (Thread[main,5,main]) completed. Took 0.002 secs.
:my-server:intTestClasses (Thread[main,5,main]) started.
:my-server:intTestClasses
Skipping task ':my-server:intTestClasses' as it has no actions.
:my-server:intTestClasses (Thread[main,5,main]) completed. Took 0.001 secs.
:my-server:intTest (Thread[main,5,main]) started.
:my-server:intTest
file or directory '/devel/my-project/src/my-server/build/classes/test', not found
Skipping task ':my-server:intTest' as it has no source files.
:my-server:intTest UP-TO-DATE
:my-server:intTest (Thread[main,5,main]) completed. Took 0.002 secs.
After changing the Test task, everything is working as expected - But IMHO, both variations should be completely equivalent and it shouldn’t make a difference. https://github.com/stackmagic/gradle-dropwizard/commit/9bbf7a555e3cf0f2f470d4671fe2142de409a597?diff=unified#diff-2
Maybe there are too many changes in the diff, the key is this (dependency on testClasses vs. own classes didn’t seem to make a difference): broken:
task(taskName, type: Test, dependsOn: 'testClasses') {
... config
}
working:
task(taskName, dependsOn: "${taskName}Classes") {
test {
... config
}
}
The way I see it, gradle is looking in the wrong place for test classes (in the default/primary test output dir) even though I set a different one. Is this a bug? And gradle won’t find anything in ‘test’ because that one actually is empty. But the intTest folder right next to it would contain the test code I want it to run.
I’d be grateful for an explanation because I’ve spent quite a bit of time ‘fixing’ this and I still don’t understand it.