-
Notifications
You must be signed in to change notification settings - Fork 393
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
[RFC] Implemented JAR minimization #273
Conversation
This commit adds two new configuration options to the 'shadowJar' task. When 'minimizeJar' is set the shadow JAR would only include the classes for the project the task operates on and its dependencies. The user can protect other classes from minimization by specifying them as entry points. Here's an example configuration shadowJar { minimizeJar = true entryPoint 'foo.Foo' entryPoint 'foo.Bar' } N.B. imported but unused classes are not considered as dependencies.
f739389
to
8c7c1af
Compare
@johnrengelman Would love to see this included. Maybe you could take a quick look, as you've been somehow absent to this repository @superbobry is there a way you could hand me over a version of your shadow plugin in the meantime? Have an urgent need for it ... |
@TheRealHypo I should point out that the patch is very experimental. I've only tested it on simple examples so far, nothing real. I don't have an artifact at hand right now, but you can easily build one by checking out the PR branch and doing |
Hey I added a Review comment on one of your files. Also I needed to include org.apache.ant and org.vager.jDependency to build script class path. |
I think you need to publish the review to make the comment visible. |
for (entryPoint in entryPoints) { | ||
Clazz clazz = cp.getClazz(entryPoint) | ||
if (clazz == null) { | ||
throw new RuntimeException("Entry point not found: " + className); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got an "Property not found Exception "className" on this line.
I tried to fix it on my own, check if the list is null etc, but after getting everything to work. The created Jar file wasn't executable, i got an error, that doesn't give me a real clue on what is missing now. But, it shrieked by 50 % that's perfect 😅
Because the Class "PeekCloppLinkExtract" is there, and also properly set in the Manifest.MF |
So I now know that all minimizing Jar Stuff won't work with groovy dependencies. Don't know why ... |
Probably are going to need a way to specify packages that should be force included. My guess is that there's a layer of indirection happening in Groovy that the dependency library can't follow. |
Just an idea - how about using ProGuard for minimization? We (Armeria project) do this when building a shaded JAR - https://github.com/line/armeria/blob/0db6ccb1a3f2c281025e031ca219ac222a849eb3/core/build.gradle#L33 |
Do you know if maven-shade-plugin is able to minimize a JAR with Groovy code correctly? |
Is this still active and/or should I help with this? |
@Fjolnir-Dvorak I haven't looked into this for a while, feel free to take it over if you want. |
Any progress about this? It's a really needed feature for projects with many dependencies. |
This is now implemented in the latest release. |
This commit adds two new configuration options to the 'shadowJar' task.
When 'minimizeJar' is set the shadow JAR would only include the classes
for the project the task operates on and its dependencies. The user can
protect other classes from minimization by specifying them as entry
points.
Here's an example configuration
N.B. imported but unused classes are not considered as dependencies.
Closes #198