我有文件夹“plugins”库,我将我的代码打包为jar(2个文件)。另外我有我的javafx应用程序,它包含 maven-assembly-plugin ,它生成带有所有依赖项的jar。
-
| -plugins
| -plugin-1.jar
| -plugin-2.jar
| - {文件名} -jar与 - depenencies.jar
是否可以混淆带有依赖关系的jar并保持目录结构。
p.s当我混淆{filename} -jar-with-depenencies.jar并复制到项目目录时一切正常,但我需要我的插件被混淆
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.app.myapp.gui.MainWindow</mainClass>
<packageName>com.app.myapp.gui</packageName>
<addClasspath>true</addClasspath>
<classpathPrefix>plugins/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.app.myapp.gui.MainWindow</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>true</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.10</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>proguard</goal></goals>
</execution>
</executions>
<configuration>
<obfuscate>true</obfuscate>
<injar>plugins\v-plugin-1.16.0-24.jar</injar>
<injar>plugins\p-plugin-1.16.0-24.jar</injar>
<injar>${project.build.finalName}-jar-with-dependencies.jar</injar> <!-- make sure to obfuscate the jar with dependencies -->
<includeDependency>true</includeDependency>
<proguardVersion>5.2</proguardVersion>
<includeDependency>true</includeDependency>
<options>
<option>-allowaccessmodification</option>
<option>-flattenpackagehierarchy ''</option>
<option>-dontoptimize</option>
<option>-dontshrink</option>
<option>-dontnote</option>
<option>-dontwarn</option> <!-- added option to ignore com.sun missing classes -->
<option>-dontusemixedcaseclassnames</option>
<option>-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod, CallbackMethods </option>
<option>-keep class !com.app.** { *; }</option>
<option>-keepclasseswithmembers public class * { public static void main(java.lang.String[]); } </option>
<option>-dontskipnonpubliclibraryclassmembers</option>
<option>-dontskipnonpubliclibraryclasses</option>
<option>-verbose</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/ext/jfxrt.jar</lib>
</libs>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
答案 0 :(得分:0)
我建议在使用proguard maven插件打包代码时对代码进行模糊处理。
因此,一旦你的jar文件到达目的地,你的情况就是插件,它们就已经被混淆了。
这将是一种更清洁的方法。
这是我可以在不查看构建过程的情况下建议的所有内容。