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

Document proguard rules #1210

Open
mikedawson opened this issue Jan 30, 2024 · 8 comments
Open

Document proguard rules #1210

mikedawson opened this issue Jan 30, 2024 · 8 comments
Labels

Comments

@mikedawson
Copy link

Hi,

When I use Proguard on my project (I'm using VLCJ in a Compose/Desktop JVM application), the discovery providers (which are loaded via Java SPI) are removed.

I think the following rules are needed:

# Not always compiling on Mac
-dontwarn com.apple.eawt.**

# Keep DiscoveryDirectoryProviders loaded via SPI
#-keep class * implements uk.co.caprica.vlcj.factory.discovery.provider.DiscoveryDirectoryProvider { *; }
#-keep interface uk.co.caprica.vlcj.factory.discovery.provider.DiscoveryDirectoryProvider { *; }

The keep rule specified here https://www.guardsquare.com/manual/configuration/examples#native is also required. I think most Proguard setups have that, but might be good to mention.

@caprica
Copy link
Owner

caprica commented Jan 30, 2024

The eawt stuff is obsolete now.

@caprica
Copy link
Owner

caprica commented Jan 30, 2024

So this is purely for purposes of minification, not obfuscation, right?

What I mean is, vlcj is Open Source so there's no point to obfuscate the source code as such. Making a small bundle size is fair enough I suppose.

@mikedawson
Copy link
Author

Thanks for the super quick reply! Yes the main point is the bundle size. Secondary reason is performance gain. My jars (also open source) are about 157MB before shrinking and obfuscation, and about 78MB afterwards (I documented a bit of it here on this article).

@mikedawson
Copy link
Author

Just to clarify: we are using obfuscation, only because it further shrinks the bundle size and should improve performance of remaining code. I find without obfuscation enabled, my jars are about 12MB bigger.

@caprica
Copy link
Owner

caprica commented Jan 30, 2024

Sure, that's what I suspected.

I am happy to add something to document this. But in the immediate term I need to think about a bit more because the upcoming version of vlcj has some more stuff that will need to be excluded.

@caprica caprica added the Task label Jan 30, 2024
@mikedawson
Copy link
Author

Adding docs would be great, thanks! On Android, libraries can publish proguard rules that are consumed automatically. Unfortunately, that hasn't hit the JVM world yet.

@caprica
Copy link
Owner

caprica commented Jan 30, 2024

is there any value just putting a proguard config file (or partial config file) in the main repo itself I wonder?

@mikedawson
Copy link
Author

I think putting in the repo (convention is META-INF/library-name.pro e.g. META-INF/vlcj.pro) would make sense. I think it would still need mentioned somewhere in the docs. On Android, those rules can be consumed automatically. On JVM, they need to be copy/pasted in manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants