如何解决模糊Maven多模块Spring Boot项目
我有一个Spring boot
的{{1}} multi-module
maven
项目正在运行。我需要使用Java8
obfuscate
。我的要求仅仅是混淆我的代码并使所有内容保持原样。所以我的项目如下所示:
proguard
依赖于Module B
。
Module A
对Module C
和Module A
都有依赖。
B
也同时依赖于Module D
和Module A
。
B
不依赖于任何其他模块。
Module E
输出Assembly
,Module C
和Module D
的jar,它们作为单独的Module E
应用程序运行。 spring boot
和Module C
的所有依赖项都进入lib dir,即Module D
有一个Module C
文件夹,该文件夹将所有其他依赖项作为jar和单独的{{ 1}}和lib
。
因此,当我们提取Module A
的Jar文件时,它看起来如下图所示:
所以我需要Module B
我的代码,以便开始使用Module C
,因此我更新了obfuscate
的{{1}}:
Module C
pom.xml
这是我的proguard.conf
Module C
当我运行<proguard.version>6.2.2</proguard.version>
命令时,它通常以三个jar结束,就像我们提取 <build>
<plugins>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>${proguard.maven.plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<proguardVersion>${proguard.version}</proguardVersion>
<proguardInclude>proguard.conf</proguardInclude>
<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
<assembly>
<inclusions>
<inclusion>
<groupId>com.xyz</groupId>
<artifactId>module-a</artifactId>
</inclusion>
<inclusion>
<groupId>com.xyz</groupId>
<artifactId>module-b</artifactId>
</inclusion>
</inclusions>
</assembly>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>${proguard.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.3.RELEASE</version>
<configuration>
<executable>true</executable>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
jar时一样,我发现结构已更改:
当我运行-libraryjars <java.home>/lib/rt.jar
-target 1.8 ##Specify the java version number
-dontshrink ##Default is enabled,here the shrink is turned off,that is,the unused classes/members are not deleted.
-dontoptimize ##Default is enabled,here to turn off bytecode level optimization
-useuniqueclassmembernames ## Take a unique strategy for confusing the naming of class members
-adaptclassstrings ## After confusing the class name,replace it with a place like Class.forName('className')
-dontnote
-ignorewarnings ## warnings are ignored
-dontwarn
-keep public class * extends org.springframework.boot.web.support.SpringBootServletinitializer
-keepdirectories ## Keep the package structure
-keepclasseswithmembers public class * { public static void main(java.lang.String[]);} ##Maintain the class of the main method and its method name
-keepclassmembers enum * { *; } ##Reserving enumeration members and methods
-keepclassmembers class * {
@org.springframework.beans.factory.annotation.Autowired *;
@org.springframework.beans.factory.annotation.Qualifier *;
@org.springframework.beans.factory.annotation.Value *;
@org.springframework.beans.factory.annotation.required *;
@org.springframework.context.annotation.Bean *;
@org.springframework.context.annotation.Primary *;
@org.springframework.boot.context.properties.ConfigurationProperties *;
@org.springframework.boot.context.properties.EnableConfigurationProperties *;
@javax.inject.Inject *;
@javax.annotation.postconstruct *;
@javax.annotation.PreDestroy *;
}
-keep class java.xml.bind.** { *; }
-keep @org.springframework.boot.autoconfigure.SpringBootApplication class org.openskye.**
-keep @org.springframework.context.annotation.Configuration class org.openskye.**
-keep @org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration class *
-keep class microsoft.exchange.webservices.** { *; }
-keep @org.springframework.cache.annotation.EnableCaching class *
-keep @org.springframework.context.annotation.Configuration class *
-keep @org.springframework.boot.context.properties.ConfigurationProperties class *
-keep @org.springframework.boot.autoconfigure.SpringBootApplication class *
-keep @org.springframework.boot.autoconfigure.batch class *
-allowaccessmodification
-keepattributes Signature
-keepattributes *Annotation*
-keepattributes EnclosingMethod
-keepattributes InnerClasses
-keepattributes Annotation
-keepdirectories com.jayk.springboot.proguard.obfuscationdemo
-keepdirectories org.springframework.boot.autoconfigure
## Do not change names of the getters and setter,if you remove this ##thymeleaf unable to find the getter and setter i.e: ##${greetingDTO.message}
-keepclassmembers class * {
*** get*();
void set*(***);
}
-keepclassmembernames class * {
java.lang.class class$(java.lang.String);
java.lang.class class$(java.lang.String,boolean);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
public static ** fromValue(java.lang.String);
}
-keepattributes RuntimeVisibleAnnotations
-keep @javax.persistence.* class * {
*;
}
-keepnames class * implements java.io.Serializable
-keepclassmembernames public class com.test.blah.config.liquibase.AsyncSpringLiquibase
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
!private <fields>;
!private <methods>;
private void writeObject(java.io.ObjectOutputStream);
private void readobject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
-keepclassmembers class * {
@org.springframework.beans.factory.annotation.Autowired *;
@org.springframework.security.access.prepost.PreAuthorize <methods>;
}
-keepclassmembers class * {
@org.springframework.beans.factory.annotation.Value *;
@org.springframework.context.annotation.Bean *;
@org.springframework.transaction.annotation.Transactional *;
}
时,它会抛出以下错误消息:
mvn clean install
请提出建议,如何以尽可能少的更改使代码模糊。任何建议将不胜感激。预先感谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。