Skip to content
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

docs: Include instructions to exclude FlatLaf from Proguard/Shadow in README.md #845

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

EchoEllet
Copy link

@EchoEllet EchoEllet commented May 21, 2024

Developers who use Proguard/Shadow JAR (Gradle Plugin) to reduce its size will get a runtime error when running the minimized JAR which leads to an unexpected bug.

The error might not be always very clear, FlatLaf uses reflection as discussed in #648, Swing depends on reflections too but the imports are already part of the JRE.

This PR add a hint for developers who are using any minimization/shrinking tool and provides a solution which is to exclude FlatLaf from being minimized instead of not disabling the minimization completely.

FlatLaf doesn't increase the bundle size too much, and minimizing it also means maintaining the rules and updating them.

If you are interested in getting this into README.md as a note, then feel free to ask me for more changes, like what should The section called and where it should be, should it only mention the use of reflection or also provide a solution to the most commonly used tools.

More details

This PR doesn't provide rules/configurations for excluding the classes that use reflections manually. Instead, it provides instructions on excluding FlatLaf completely from minimization by Proguard/Shadow JAR to avoid any runtime errors.

Flatlaf size is quite small compared to the features it provides, usually, you will save around 0.5 MB in best cases by explicitly keeping the classes that use dynamic class loading or reflections.

If you update the usage of reflections or create more classes that use reflections, there will be no need to update this section.

While it seems clear when using Shadow JAR, on Proguard it requires an additional step. It was already in the docs however the details were quite specific and generic.

I was able to minimize a open-source app I'm currently working on and save space up to more than 60% while still using Flatlaf:

image

The size can be even lower when providing specific rules to keep only the classes that are using reflections and dynamic class loading which is not what this PR does.

Previously, I did a workaround by disabling the FlatLaf themes feature when using Proguard

Thank you for your efforts in this library.

@EchoEllet EchoEllet marked this pull request as draft June 2, 2024 20:27
@EchoEllet EchoEllet marked this pull request as ready for review June 6, 2024 07:11
@EchoEllet EchoEllet changed the title docs: Include a note when using Proguard/Shadow with FlatLaf in README.md docs: Include instructions to exclude FlatLaf from Proguard/Shadow in README.md Jul 8, 2024
@EchoEllet EchoEllet marked this pull request as draft September 10, 2024 13:44
@EchoEllet EchoEllet marked this pull request as ready for review September 10, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants