docs: Include instructions to exclude FlatLaf from Proguard/Shadow in README.md #845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.