0

我试图混淆我生成的项目 JAR 文件,但没有成功。所以我试图减少所有步骤以找出发生了什么,我意识到我根本无法使用 yguard,我不知道为什么。也许是一个 Eclipse 糟糕的配置......

我在 pom.xml 中添加了 yguard

        <dependency>
            <groupId>com.yworks</groupId>
            <artifactId>yguard</artifactId>
            <version>3.0.0</version>
        </dependency>

我在 pom.xml 和执行(在打包期间)中添加了试图混淆单个 JAR 文件

<execution>
    <id>Obfuscate</id>
    <phase>package</phase>
    <goals>
        <goal>run</goal>
    </goals>
    <configuration>
        <tasks>
            <property name="runtime-classpath" refid="maven.runtime.classpath"/>
            <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="${runtime-classpath}"/>
            <yguard>
                <inoutpair in="C:/test/example.jar" out="C:/test/example_obfuscated.jar" />
                <shrink/>
            </yguard>
       </tasks>
    </configuration>
</execution>

“example.jar”正确放置在“C:/test”中,只是一个手动生成的类文件(为了简化我的混淆测试)。

jar cf example.jar myClass.class

当我运行任何包含包阶段的 MAVEN 进程时,执行失败并且我收到以下控制台消息:

main:
   [shrink] yGuard Shrinker v3.0.0 - http://www.yworks.com/products/yguard
   [shrink] no entrypoints given - using class access public and protected on all inoutpairs.
   [shrink] ERROR: class com.yworks.yshrink.model.ModelVisitor has interface org.objectweb.asm.ClassVisitor as super class
   [shrink] class com.yworks.yshrink.model.ModelVisitor has interface org.objectweb.asm.ClassVisitor as super class
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.382 s
[INFO] Finished at: 2022-01-20T14:32:24+01:00
[INFO] Final Memory: 54M/714M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (Obfuscate) on project grb: An Ant BuildException has occured: yShrink encountered an unknown severe problem!
[ERROR] around Ant part ...<yguard>... @ 6:11 in C:\espacio_trabajo_7\eclipse\eclipse_2019-09\workspace\trunk\grb\target\antrun\build-main.xml: class com.yworks.yshrink.model.ModelVisitor has interface org.objectweb.asm.ClassVisitor as super class
[ERROR] -> [Help 1]`

任何想法?我非常感谢您能提供的任何帮助。

伊万

4

1 回答 1

0

问题也与使用 asm 工件的其他库有关。所以我不得不做以下事情:

1- 从 yguard 中排除 asm

2-将 asm 添加到我的 pom.xml

3-从其他库中排除所有 asm 引用(在我的情况下为 2 个库):1-jasperreports 使用了 itext 和 olap4j,它们都使用了 asm 2-retroweaver

4-手动添加排除的库

    <dependency>
        <groupId>com.yworks</groupId>
        <artifactId>yguard</artifactId>
        <version>3.0.0</version>
        <exclusions> 
            <exclusion>
                 <groupId>org.ow2.asm</groupId>
                 <artifactId>asm</artifactId>
            </exclusion>    
        </exclusions>           
    </dependency>       
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>7.2</version>
    </dependency>
    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>6.4.1</version>                    
        <exclusions> 
            <exclusion>
                 <groupId>com.lowagie</groupId>
                 <artifactId>itext</artifactId>
            </exclusion>
            <exclusion>
                 <groupId>org.olap4j</groupId>
                 <artifactId>olap4j</artifactId>
            </exclusion>                                                    
        </exclusions>                                   
    </dependency>       
    <dependency>
        <groupId>net.sourceforge.retroweaver</groupId>
        <artifactId>retroweaver</artifactId>
        <version>1.2.4</version>    
        <exclusions> 
            <exclusion>
              <groupId>asm</groupId>
              <artifactId>asm</artifactId>
            </exclusion>    
        </exclusions>                           
    </dependency>       
    <dependency>
        <groupId>org.olap4j</groupId>
        <artifactId>olap4j</artifactId>
        <version>0.9.7.309-JS-3</version>
        <exclusions> 
            <exclusion>
                 <groupId>net.sourceforge.retroweaver</groupId>
                 <artifactId>retroweaver</artifactId>
            </exclusion>
            <exclusion>
                <groupId>asm</groupId>
                <artifactId>asm</artifactId>
            </exclusion>                                                                    
        </exclusions>           
    </dependency>
于 2022-01-25T14:26:38.740 回答