gpt4 book ai didi

java - Proguard 混淆 如何混淆多个 jars,并保持目录结构

转载 作者:行者123 更新时间:2023-12-02 11:16:34 35 4
gpt4 key购买 nike

我有文件夹“plugins”库,我将代码打包为 jar(2 个文件)。我还有我的 javafx 应用程序,它包含 maven-assemble-plugin ,它生成具有所有依赖项的 jar。
--
|-插件
|-plugin-1.jar
|-plugin-2.jar
|-{文件名}-jar-with-dependency.jar

是否可以不仅用依赖项混淆 jar 并保留目录结构。

p.s 当我混淆 {filename}-jar-with-depencies.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>

最佳答案

我建议在使用 proguard maven 插件打包代码时对代码进行混淆。

因此,一旦您的 jar 文件到达目的地(在您的情况下是插件),它们就已经被混淆了。

这将是一种更简洁的方法。

这就是我在不查看您的构建过程的情况下所能提供的建议。

关于java - Proguard 混淆 如何混淆多个 jars,并保持目录结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50232831/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com