[GRADLE-1885] Jar task should not create build/tmp/x directory when it's not executed Created: 02/Nov/11 Updated: 04/Jan/13 Resolved: 06/Dec/11
|Reporter:||Matias Bjarland||Assignee:||Luke Daley|
and the following gradle execution:
we get the following resulting directory structure:
note that we started from an empty directory.
note among other things the 'temporaryDir' variable access. This comes from a super class a bunch of inheritance levels up:
notice the 'dir.mkdirs()'. So to summarize: just by instantiating the Jar task class we will create the directory structure described above. This is independent of whether we have elected do disable the jar task entirely, excluded it from the execution graph, added an onlyIf clause etc etc.
Note that we get the same result with the following build file:
and just executing 'gradle tasks'.
I think this behavior is unexpected and undesirable. In large multi-project builds where we want to leave directories without sources or resources well alone, this becomes a serious issue.
In addition, creating a clean workaround by selectively deleting the build directory only when it was erroneously created by the jar task is actually non-trivial. How do you figure out if the Jar task erroneously created the directory? And if it did, where do you add the code to remove the directory? jar.doLast doesn't work as (in my specific example) I have disabled the jar task and jar.doLast is therefore not executed. Adding this to assemble.doLast works but gets hairy with the state management to only do this when the jar task did the wrong thing.
|Comment by Matias Bjarland [ 07/Nov/11 ]|
Verified, still an issue in 1.0-milestone-5
|Comment by Luke Daley [ 06/Dec/11 ]|
Fixed in m7.