I’m working on a incremental task plugin that needs to inject code in class files. Because of it it monitors changes in the targetDirectory.
For the first run everything goes well and classes are injected with necessary modifications. Although, when executing for the second time, the Java Plugin compileTestJava task will detect those changes and rebuild the classes once again and with it removing the introduced modifications.
This does not seem to be the appropriate behavior for such task as it should only monitor for changes in the source directories. The question is… why is the compileTestJava task monitoring the targetDirectory and, how can I avoid it from doing so?
./gradlew build -i Starting Build Settings evaluated using empty settings script. Projects loaded. Root project using build file ‘/Users/thename/git/cola-gradle-plugin/consumer/build.gradle’. Included projects: [root project ‘consumer’] Evaluating root project ‘consumer’ using build file ‘/Users/thename/git/cola-gradle-plugin/consumer/build.gradle’. Incremental java compilation is an incubating feature. All projects evaluated. Selected primary task ‘build’ from project : Tasks to be executed: [task ‘:compileJava’, task ‘:processResources’, task ‘:classes’, task ‘:jar’, task ‘:assemble’, task ‘:compileTestJava’, task ‘:processTestResources’, task ‘:testClasses’, task ‘:icolac’, task ‘:test’, task ‘:check’, task ‘:build’] :compileJava (Thread[main,5,main]) started. :compileJava Skipping task ‘:compileJava’ as it is up-to-date (took 0.042 secs). :compileJava UP-TO-DATE :compileJava (Thread[main,5,main]) completed. Took 0.07 secs. :processResources (Thread[main,5,main]) started. :processResources Skipping task ‘:processResources’ as it has no source files. :processResources UP-TO-DATE :processResources (Thread[main,5,main]) completed. Took 0.003 secs. :classes (Thread[main,5,main]) started. :classes Skipping task ‘:classes’ as it has no actions. :classes UP-TO-DATE :classes (Thread[main,5,main]) completed. Took 0.001 secs. :jar (Thread[main,5,main]) started. :jar Skipping task ‘:jar’ as it is up-to-date (took 0.013 secs). :jar UP-TO-DATE :jar (Thread[main,5,main]) completed. Took 0.017 secs. :assemble (Thread[main,5,main]) started. :assemble Skipping task ‘:assemble’ as it has no actions. :assemble UP-TO-DATE :assemble (Thread[main,5,main]) completed. Took 0.002 secs. :compileTestJava (Thread[main,5,main]) started. :compileTestJava Executing task ‘:compileTestJava’ (up-to-date check took 0.117 secs) due to:
Output file /Users/thename/git/cola-gradle-plugin/consumer/build/classes/test/org/gradle/cola/tests/TestBase.class has changed.
Output file /Users/thename/git/cola-gradle-plugin/consumer/build/classes/test/org/gradle/cola/tests/PersonTest.class has changed. All input files are considered out-of-date for incremental task ‘:compileTestJava’. Compiling with JDK Java compiler API. :compileTestJava (Thread[main,5,main]) completed. Took 0.517 secs. :processTestResources (Thread[main,5,main]) started. :processTestResources Skipping task ‘:processTestResources’ as it is up-to-date (took 0.006 secs). :processTestResources UP-TO-DATE :processTestResources (Thread[main,5,main]) completed. Took 0.011 secs. :testClasses (Thread[main,5,main]) started. :testClasses Skipping task ‘:testClasses’ as it has no actions. :testClasses (Thread[main,5,main]) completed. Took 0.001 secs. :icolac (Thread[main,5,main]) started. :icolac …