XML
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.inomec.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- ProGuard Maven plugin -->
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<injar>${project.build.finalName}.jar</injar>
<outjar>test.jar</outjar>
<proguardInclude>src/main/resources/proguard.cfg</proguardInclude>
<logFile>proguard.log</logFile>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jce.jar</lib>
<lib>${java.home}/lib/jsse.jar</lib>
</libs>
</configuration>
</plugin>
</plugins>
</build>
</project>
XML
# proguard.cfg
# Keep the main class and its methods
-keep class com.inomec.Main {
public static void main(java.lang.String[]);
}
-keep class com.inomec.ServerMethodsWrapper {
*;
}
-keepdirectories META-INF
# Optimization options
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
pom.xml文件中先使用 maven-jar-plugin 对工程进行打包,设置好入口类,正常生成jar文件。
proguard插件的配置中,injar为上面已经打好包的jar文件。
并设置输出jar名称。
指定配置文件proguard.cfg。
指定使用的库文件地址。