-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
shadowJar breaks Gradle artifact transforms #882
Comments
@DreierF I re-discovered the workaround for this issue I did in another build:
|
A better workaround that also works with configuration cache:
|
We've run into this too. It occurs to me both the resolution of artifacts at configuration time, and the problem with the missing inputs could be addressed by returning a detached configuration that That will let Gradle defer calculation of the classpath input until execution time, and also ensure that implicit dependencies on the tasks that produce the artifacts are wired. |
Related upstream issue: gradle/gradle#26155 |
Thanks for the issue link @DanielThomas. I have been searching for that one. |
Shadow Version
8.1.1
Gradle Version
8.3
Expected Behavior
I can use artifact transforms on my dependencies in combination with the shadow plugin to shade the result of the transformed dependencies.
Actual Behavior
When the
runtimeClasspath
requires an artifact transform running theshadowJar
task results inAccording to @jjohannes this is caused by dependency resolution being triggered too early. There is only a particular window between the "main" configuration time and before any task starts in which transforms should/can run. But Gradle does not check that well and you get unexpected/inconsistent errors. This
resolve()
is triggered during configuration time.The
resolvedConfiguration
access here seems to be the problematic part.That should not be done and instead the filtering implemented there should be done lazily at a later point. It breaks transforms.
Reproduction
A full minimal reproduction setup can be found here:
reproduction-gradle-shadow-artifact-transform.
It consists of an app module and a lib module and a NoOp artifact transform. The error can be reproduced with
./gradlew clean shadowJar
.Workaround
In case other people run into this: I worked around the issue for now by running
./gradlew jar && ./gradlew shadowJar
in CI, because it firsts builds the expected jar files and then can pick them up during the second invocation. This is quite a hacky solution, but the only thing I could get to work.The text was updated successfully, but these errors were encountered: