fabric-loom
fabric-loom copied to clipboard
The `runDatagen` task can never be cached by gradle, as it depends on its own outputs
The run datagen task can never be cached by gradle, as its inputs will always depend on its outputs.
Reproducing:
- Create simple fabric mod with data generation enabled
- Add the following code (kotlin; too lazy to port to groovy. the steps to reproduce still match up without this code, this code just helps understand it)
tasks { val runDatagen by named("runDatagen") { doFirst { println(inputs.files.files) } } processResources { doFirst { println(inputs.files.files) println(outputs.files.files) } } }
- Run the
runDatagen
task several times without changing anything.
Expected:
All runs after the first are cached.
Actual:
None of the runs are cached.
Using the print statements, you can see that the runDatagen
task depends on its own outputs in the following manner:
-
processResources
-> takes/src/main/generated/
as an input -
processResources
-> outputs to/build/resources/main/
-
runDatagen
-> takes/build/resources/main/
as an input -
runDatagen
-> outputs to/src/main/generated/
Since processResources
is never cached and always re-run, this causes runDatagen
to always be re-run.
This is quite annoying for people who don't want to check src/main/generated/*
into VCS, and instead have their jar
task depend on runDatagen
(to ensure the generated resources always remain up to date), as it will cause runDatagen
to constantly be re-run, even when no changes have been made.