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

Shrink CLI fat JAR #275

Open
armiol opened this issue Oct 15, 2024 · 0 comments
Open

Shrink CLI fat JAR #275

armiol opened this issue Oct 15, 2024 · 0 comments

Comments

@armiol
Copy link
Collaborator

armiol commented Oct 15, 2024

Right now, protodata-fat-cli-<version>.jartakes approximately 170-180 MB. And it obviously carries a lot of redundant things with it/

In scope of this task, we should try and append the shrinking step to the CI pipeline.

The idea is to use ProGuard along with its Gradle plugin.

Here is the preliminary ProGuard ruleset with which ProGuard 7.2.2 in its standalone mode completes the shrinking process:

-injars  	./protodata-fat-cli-<version>.jar
-outjars     	./protodata-fat-cli-<version>-out.jar

-libraryjars <YOUR_PATH_HERE>/zulu-11.jdk/Contents/Home/jmods/java.base.jmod(!**.jar;!module-info.class):<YOUR_PATH_HERE>/zulu-11.jdk/Contents/Home/jmods/java.desktop.jmod(!**.jar;!module-info.class)


-dontoptimize
-dontwarn
-dontobfuscate

# Uncomment if you want to see ~350K of warnings.
# -verbose

-keepattributes *Annotation*
-keepattributes Signature
-keepattributes InnerClasses
-keepattributes InnerClasses,EnclosingMethod


-keep class kotlin.Metadata
-keep,includedescriptorclasses class io.spine.** { *; }

-keep,includedescriptorclasses class com.google.common.** { *; }
-keep,includedescriptorclasses class com.google.protobuf.** { *; }

(where YOUR_PATH_HERE should be changed to the corresponding value).

The resulting JAR was NOT tested. But the size was down 177 MB -> 56.8 MB.

Another room for improvement is with the static resources . There are tons of these in our JAR. And ProGuard has no means to detect whether they are used.

⚠️ With the most recent version of ProGuard (7.6.0, as of the moment of writing), this issue arises.

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

No branches or pull requests

1 participant