I'm trying to obfuscate my generated project JAR file with no success. So I tried to reduce all the steps in order to find out what is going on and I've realized that I cannot use yguard at all and I don't know why. Maybe is an eclipse bad configuration...
I added the yguard in my pom.xml
<dependency>
<groupId>com.yworks</groupId>
<artifactId>yguard</artifactId>
<version>3.0.0</version>
</dependency>
And I added in the pom.xml and excution (during packaging) that tries to obfuscate a single JAR file
<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" is properly placed in "C:/test" and is simply a class file generated manually (in order to simplify my obfuscation test).
jar cf example.jar myClass.class
When I run any MAVEN process that includes the package phase, the execution fails and I receive the following console message:
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]`
Any idea? I really appreciate any help you can provide.
Ivan
Problem was related to other libraries that uses the asm artifact too. So I had to do the following:
1- Exclude asm from yguard
2- Add asm to my pom.xml
3- Exclude all the asm references from other libraries (in my case 2 libraries): 1- jasperreports used itext and olap4j that both used asm 2- retroweaver
4- Add manually the excluded libraries