Java SpringBoot maven using Proguard

I try to use Proguard in my maven project (in pom.xml), but when I run command `

mvn clean package

it raise error: Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.3.1:proguard (default) on project api: Obfuscation failed (result=1) → [Help 1]. Does anything need be installed more? Thanks all. have a nice day!

my pom:

 <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.3.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <proguardVersion>${proguard.version}</proguardVersion>
                    <injar>${project.build.finalName}.jar</injar>
                    <outjar>${project.build.finalName}.jar</outjar>
                    <obfuscate>true</obfuscate>
                    <options>
                        <option>-dontshrink</option>
                        <option>-dontoptimize</option>
                        <!-- This option will replace all strings in reflections method invocations with new class names.
                             For example, invokes Class.forName('className')-->
                        <option>-adaptclassstrings</option>
                        <!-- This option will save all original annotations and etc. Otherwise all we be removed from files.-->
                        <option>-keepattributes
                            Exceptions,
                            InnerClasses,
                            Signature,
                            Deprecated,
                            SourceFile,
                            LineNumberTable,
                            *Annotation*,
                            EnclosingMethod
                        </option>
                        <!-- This option will save all original names in interfaces (without obfuscate).-->
                        <option>-keepnames interface **</option>
                        <option>-keepnames public class * implements *</option>
                        <!-- This option will save all original methods parameters in files defined in -keep sections,
                             otherwise all parameter names will be obfuscate.-->
                        <option>-keepparameternames</option>
                        <!-- This option will save all original class files (without obfuscate) but obfuscate all
                             in domain and service packages.-->
                        <option>-keepclasseswithmembers public class com.beowulf.noc.api.BeowulfNOCApiV1Application {
                            public static void main(java.lang.String[]);
                            }
                        </option>
                        <!-- This option ignore warnings such as duplicate class definitions and classes in incorrectly
                            named files-->
                        <option>-ignorewarnings</option>
                        <!-- This option will save all original class files (without obfuscate) in service package-->
                        <!-- <option>-keep class com.slm.proguard.example.spring.boot.service { *; }</option>-->
                        <!-- This option will save all original interfaces files (without obfuscate) in all packages.-->
                        <option>-keep interface * extends * { *; }</option>
                        <!-- This option will save all original defined annotations in all classes in all packages.-->
                        <option>-keep class com.slm.proguard.example.spring.boot.config.BeanConfig</option>
                        <option>-keep class com.fasterxml.jackson.** { *; }</option>
                        <option>-keep class org.json.JSONObject.** {** put(java.lang.String,java.util.Map);}</option>
                        <option>-keepclassmembers class * {
                            @org.springframework.context.annotation.Bean *;
                            @org.springframework.beans.factory.annotation.Autowired *;
                            @org.springframework.beans.factory.annotation.Value *;
                            }
                        </option>
                        <option>-dontwarn com.fasterxml.jackson.databind.**</option>
                        <option>-dontwarn com.fasterxml.jackson.**</option>
                    </options>
                    <injarNotExistsSkip>true</injarNotExistsSkip>
                    <libs>
                        <lib>${java.home}/lib/rt.jar</lib>
                        <lib>${java.home}/lib/jce.jar</lib>
                    </libs>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.guardsquare</groupId>
                        <artifactId>proguard-base</artifactId>
                        <version>${proguard.version}</version>

                    </dependency>
                </dependencies>
            </plugin>

Hi @test_dev,

Welcome! After examination, it appears it is not our plugin where the issue occurs, so we would advise opening this issue on the plugin’s Github page. We don’t officially provide a Maven integration or support but that should be a good first step for you.

Thanks for your time here and let us know how it goes,
Jesse

Hi Jesse ,

Do you provide support for gradle ?

Hi @Waheed_Khan,

For non-Android yes: e.g. here’s an example application that uses Gradle https://github.com/Guardsquare/proguard/tree/master/examples/application

For Android: ProGuard no longer supports AGP since AGP 8.

I hope this helps and have a great day!
Jesse

Thanks Jesse your answer is helpful. I have one more query. Do proguard supports spring boot project that uses maven ? or gradle with spring boot ? if yes then then how as spring uses reflection too much. As I have done some R&D on this.

Its not going to work with spring based applications as these apps use reflection too much.

I have also put a question on this. If you could guide me that will be very helpful.