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.77k stars 395 forks source link

Collision logging, Transformers for JSON and Standard Files #962

Open Master-Code-Programmer opened 2 months ago

Master-Code-Programmer commented 2 months ago

This is the PR #773, but on a new, rebased branch (the original PR was made 2 years ago).

Hi, I fitted the collsion_logging merge request from chapmajs to your current source code (https://github.com/johnrengelman/shadow/pull/126). Also I followed your wish to use typed parameters (which was really needed, because after adding them, some problems became obvious).

After that I used the modified plugin and with the warnings I could fix my problems instantly. Great!

The only problem was, that I was flooded with warnings about colliding META-INF/NOTICE, META-INF/license.txt, readme.txt and similar files. So I added a transformer, StandardFilesMergeTransformer, which takes these standard files, which exist in all big projects in big numbers, and merges them. Since these are all pretty primitive files regarding their structure, no special YAML or JSON files, I just concatenate their contents the following way:

With that changes, any user should be capable to build a fat JAR with more than one Spring (Boot) dependency, right out of the box. Otherwise it's a real pain to find out which files collide, and how to merge colliding JSON files, since that is the only colliding file type, which misses a merging transformer from this plugin. And JSON is very common!

Goooler commented 2 months ago

Sorry for the delay. Can you rebase again? I changed a lot on the main...

Master-Code-Programmer commented 2 months ago

Sorry for the delay. Can you rebase again? I changed a lot on the main...

Did the rebase.