Java Proguard obfuscation on multiple projects at once (or save interface include definitions)?
Asked Answered
S

0

6

I'm obfuscating/optimizing an app and a set of plugin/libraries (using ServiceLoader) via maven.

The plugins are only created/maintained in the same code base as the app, it's not an interface intended for 3rd party development against, so obfuscation is desired.

I'd like to be able to obfuscate the App code that's included in the plugin interface class. The only way I can think to do this is to run proguard on the app and the plugins at the same time (or somehow have proguard save the app run information for usage in the plugin compilation). Is this possible? Or, will I have to leave any included code unobfuscated?

I'm using separate maven pom files to build the app and plugins right now. Could I add the proguard stage to a top level pom file that includes the app and plugin poms?

Here's what the interface looks like, I'd like to be able to obfuscate AppClass1 and AppClass2, using proguard on the app first I can't do this.

package com.project.app;

public interface RunPlugin {

    public int plugin_function(AppClass1 a1, AppClass2 a2);

}

Also, I suppose I'd technically need to compile the plugin using the proguard generated .jar and it'd have to know the entity mapping.

The error I'm getting, which is straightforward and expected, is

Caused by: java.lang.AbstractMethodError: Receiver class com.project.dummy.RunCustomPlugin does not define or inherit an implementation of the resolved method 'abstract int plugin_function(com.project.app.o, com.project.app.b)' of interface com.project.app.RunPlugin.
        at com.project.app.o.<init>(Unknown Source)
        at com.project.app.m.a(Unknown Source)
        at com.project.app.m.call(Unknown Source)

Apologies if there's a proguard reference on doing this - couldn't find anything other than saying not to obfuscate the required app classes.

Sterigma answered 6/7, 2021 at 17:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.