Improve cache effectives for inputs to ShadowJar task #470
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ShadowJar
has currently two important inputs. https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java#L333-L336 and https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java#L98-L107The
getIncludedDependencies
is actually derived from thegetConfigurations
The derivation process is the application of filters. I'm working on a use case described in #443. I have a multi-module project. One module produces two shadow jar. One is including classes from all submodules the other is including dependencies. In a configuration of shadow jar, I'm doing to achieve that result:There is a lot of dependencies and the creation of dependencies jar should not be done unless it is necessary. Unfortunately, when I change the code in
common-submodule
it generates a new jar which leads to modification ofconfigurations.runtime
and becausegetConfigurations
is marked as@InputFiles
it invalidates task cache ant retriggers the execution. It could be avoided because the changed jar is filtered out from the configuration and final result ofgetIncludedDependencies
would be unchanged.I would like to propose marking
getConfigurations
as@Internal
leaving only the final result of filtering as cached. It would help avoid cache invalidation. I talked to Gradle team to double check that I'm not doing anything unexpected from Gradle point of view and I was told this is quite a common pattern even in Gradle itself.