I thought I understood how up-to-date checks happen for task, but I seem to have been wrong…
I have a plugin which will optionally trigger adding the java-library
plugin based on whether a certain block is used in my plugin’s DSL extension.
The project where my plugin is applied is not originally a java-library and has no sources of its own. My plugin “generates” sources and then links them into the project’s sourceSets.main.allJava.srcDir
.
My understanding is that linking the output from my generation into the projects main source-set’s java dirs would be enough. But simply doing that, the project’s compile task is always skipped with NO_SOURCE
.
Is it maybe a timing issue? My plugin applying java-library
still happens during config phase, so it should be good. I print out a few seemingly important information about the project, but everything points to the compile
should be triggered.
Copy dir `/home/sebersole/projects/playground/jakarta-transformer-plugin/build/tmp/testKit/testKit1691600008/shadowMulti/shadow/build/jakarta/transform/shadow/real/src/main/java` exists? : true
`sourceSet.main.allJava` -> /home/sebersole/projects/playground/jakarta-transformer-plugin/build/tmp/testKit/testKit1625958045/shadowMulti/shadow/src/main/java:/home/sebersole/projects/playground/jakarta-transformer-plugin/build/tmp/testKit/testKit1625958045/shadowMulti/shadow/build/jakarta/transform/shadow/real/src/main/java
`(:shadow:compileJava).input.hasSourceFiles` - true
- “Copy dir” is where the generated sources go. Relatively, this is
build/jakarta/transform/shadow/real/src/main/java
- The main source-set’s java dirs contains both the conventional dir (src/main/java) as well as this copy-dir. I tried setting the source-dirs to contain just the copy-dir thinking the empty
src/main/java
might be the problem. But I could not figure out how to completely replace the source-dirs or remove one - “has sources” comes from
tasks.compile.inputs.hasSourceFiles
What am I missing?