GradleUp / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
https://www.gradleup.com/shadow/
Apache License 2.0
3.69k stars 389 forks source link

Configuring publishing before shadowJar publishes jar with wrong configuration #945

Open gharris1727 opened 3 weeks ago

gharris1727 commented 3 weeks ago

Originally reported in https://github.com/Goooler/shadow/issues/106

I discovered that my project was configuring publishing before the actual shadowJar, which was causing the wrong classifier to get picked up by the shadow plugin. Is this a reasonable situation that could be improved with lazy evaluation, or should I restructure my build file to configure shadowJar first?

Shadow Version

8.1.4-8.1.8 of Goooler's fork

Gradle Version

8.8

Expected Behavior

The archive published has the classifier that I specified in shadowJar archiveClassifier

Actual Behavior

The archiveClassifier is all

Gradle Build Script(s)

See this modified unit test in my fork, which is failing: https://github.com/gharris1727/shadow/blob/772444c88e9fbec864364fdc5de6134bb4ccfa2f/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy#L81-L127

Content of Shadow JAR (jar tf - post link to GIST if too long)

N/A

gharris1727 commented 3 weeks ago

It appears that the test I provided is failing not due to eager evaluation (a flaw in the patch proposed in #904) but because the patch #904 is not present at all in this fork, and the original bug #860 is still unresolved.

This is a warning for anyone that was relying on fixes in https://github.com/Goooler/shadow/pull/80 in Goooler's 8.1.4-8.1.8, that the new 8.3.0 release may be missing some of of those changes.

gharris1727 commented 1 week ago

@Goooler Please reopen this issue, as it is not fixed by #904. I have updated the reproduction case with the latest main and it's still failing: https://github.com/gharris1727/shadow/blob/7af7461081f60bbfc066d53579e780191700af91/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy#L81-L127

This issue is about the order-sensitivity of the #904 patch, which did not get fixed since 8.1.4-8.1.8.

Goooler commented 1 week ago

Thanks for the headsup!

Cause we can't obtain the correct archiveClassifier in this case, as a workaround, please configure shadowJar before publishing.

https://github.com/GradleUp/shadow/blob/ae72788e9475da71cb3874239723eb91839f9ba5/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowExtension.groovy#L19-L20