Open mkobit opened 6 years ago
Pull requests welcome for documentation
I'm interested to see any tips on this one...
I've been struggling for a while now to figure out how to get the shadow
(or plugin-shadow
), java-gradle-plugin
, and maven-publish
to play nice and publish the shadowjar instead of the regular jar.
@fitzoh Just curious if you made any progress on this. I'm thinking of using plugin-shadow
as a way to publish a plugin that includes libraries not existent in jcenter. Wondering if this is a reasonable use case, whether it's possible, and if you had success.
Sorry @stewartbryson, no luck here
I've had a fair bit of luck doing this. I can take a stab at documentation. How do I submit docs?
@maguro It looks like (to me) an AsciiDoctor site at https://github.com/johnrengelman/shadow/tree/master/src/docs/asciidoc gets built/published with GitHub pages at https://github.com/johnrengelman/shadow/tree/gh-pages . Looking at https://github.com/johnrengelman/shadow/commit/5617cb70b05e41c07fc309f0b9b4e43c678d3079 , those pages are generated by one of the Gradle plugins applied and running a command in the repository.
Hopefully that is helpful/accurate. I think probably submitting a PR for the asciidoc would probably be the right path.
@maguro Any teaser snippets?
Thanks anyway @fitzoh
This plugin itself uses java-gradle-plugin, shadow-plugin, and maven-publish plugins and publishes the shadowed jar file. See the build.gradle and gradle/publish.gradle files in this project.
That’s so meta. 😉 Thanks @johnrengelman I’ll take a look.
@johnrengelman Saw the note on removing plugin-shadow
with a preference not just using shadow
. That makes sense. It's a lack of knowledge, but I don't necessarily understand the need for the Relocate need, and how it relates to Plugins. I assume that during dependency resolution, a class that has been shaded inside the JAR would take precedence over the POM. Is that what the Relocation does... update the POM reference to the class inside the JAR?
Thanks for a great plugin.
The relocate task does scanning of your classpath and sets up all the packages it finds to be relocated. This removes the need of having to define each package relocation manually in the shadow task config.
It’s useful if you are writing a Gradle plugin because Gradle plugins have a tendency at to leak classes (getting better)
Using the
'java-gradle-plugin'
(from https://docs.gradle.org/current/userguide/java_gradle_plugin.html) should be documented as it is generally the preferred way to build, test, and publish plugins in more recent versions of Gradle.