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

springboot project + multi maven module #102

Open
sjr7 opened this issue Sep 23, 2019 · 2 comments
Open

springboot project + multi maven module #102

sjr7 opened this issue Sep 23, 2019 · 2 comments

Comments

@sjr7
Copy link

sjr7 commented Sep 23, 2019

I have a project now that is a springboot project. It contains 3 modules , module A depends on module B and module B depends on module C in a maven project . Now we want to obfuscate A module, B module, C module . Finally get a jar package and the code of the A、B、C、D module is obfuscated .
My steps:

  1. Configuring proguard-maven-plugin in module A .
    pom.xml as follows

    <plugin>
              <groupId>com.github.wvengen</groupId>
              <artifactId>proguard-maven-plugin</artifactId>
              <version>2.1.1</version>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals>
                          <goal>proguard</goal>
                      </goals>
                  </execution>
              </executions>
              <configuration>
                  <attach>true</attach>
                  <obfuscate>true</obfuscate>
                  <attachArtifactClassifier>pg</attachArtifactClassifier>
                  <options>
                      <option>-printmapping '${project.build.directory}/${project.artifactId}.log'</option>
                      <option>-ignorewarnings</option>
                      <option>-dontshrink</option>
                      <option>-dontoptimize</option>
                      <option>-dontskipnonpubliclibraryclasses</option>
                      <option>-dontskipnonpubliclibraryclassmembers</option>
                      <option>-allowaccessmodification</option>
                      <option>-useuniqueclassmembernames</option>
                      <option>-keeppackagenames</option>
                      <option>-adaptclassstrings</option>
                      <!-- <option>-keepdirectories</option> -->
                      <option>-keepattributes
                          Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
                      </option>
                      <option>-keepnames interface **</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>
                      <option>-keepclassmembers class * {
                          @org.springframework.beans.factory.annotation.Autowired *;
                          @org.springframework.beans.factory.annotation.Value *;
                          @org.springframework.context.annotation.Bean *;
                          @org.springframework.beans.factory.annotation.Qualifier *;
                          @org.springframework.stereotype.Repository *;
                          @org.springframework.data.repository.NoRepositoryBean *;
                          }
                      </option>
                      <option>-keepclassmembers enum * { *; }</option>
    
                      <option>-keep class * implements java.io.Serializable</option>
                      <option>-keep class com.suny.demo.main.MainModuleApplication { *; }</option>
                      <option>-keepclassmembers public class * {void set*(***);*** get*();}
                      </option>
      
                  </options>
    
    
                  <outjar>${project.build.finalName}-pg.jar</outjar>
                  <libs>
                      <lib>${java.home}/lib/rt.jar</lib>
                      <lib>${java.home}/lib/jce.jar</lib>
                  </libs>
      
                  <injar>classes</injar>
                  <outputDirectory>${project.build.directory}</outputDirectory>
              </configuration>
          </plugin>
  2. B module and C module don't obfuscated plugin

  3. Execute mvn package

  4. Finally , The B and C module code is not obfuscated .

So , The result did not achieve my expected results .

I know this is a proGuard configuration file issue, not a bug . No similar configuration example in the documentation for my view of the plugin. So I want to ask if there is any suggestion for me. Thanks !

@lasselindqvist
Copy link
Collaborator

If I understood correctly, you would like to have an example where defining this plugin in module A only would be able to obfuscate some of its dependencies at the same time.

Some options include:

  1. having multiple executions in the Maven config, one for each module
  2. using inclusions to include all the needed modules inside a single execution
  3. forming a single uber jar with some other plugin (for example maven-shade-plugin) and then obfuscating this. In this option you need to be careful with the licenses of the dependencies, so make sure you are allowed to modify all the dependencies you would distribute in the end result.

I would happily merge any new examples for any of these options or I might even produce one myself, if you can provide an example project.

@rdinkel
Copy link

rdinkel commented Jun 14, 2023

Did you found a solution to this?
Please let me know as I need it too.

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

3 participants