Running proguard on application code puts unit tests

I am trying to obfuscate the code mostly (see project structure below) using proguard-maven-plugin. Obfuscation seems to work fine, but when I get to the testing phase, I get compilation errors, since test classes have never been part of obfuscation.

Main / Java / com.foo.bar.HelloWorld.java

Test / Java / com.foo.bar.HelloWorldTest.java

My maven pom is configured like this:

<plugin> <groupId>com.github.wvengen</groupId> <artifactId>proguard-maven-plugin</artifactId> <version>2.0.6</version> <executions> <execution> <id>process-classes-with-proguard</id> <phase>process-test-classes</phase> <goals> <goal>proguard</goal> </goals> <configuration> <proguardVersion>4.8</proguardVersion> <maxMemory>256m</maxMemory> <injar>classes</injar> <libs> <lib>${java.home}/../Classes/classes.jar</lib> </libs> <addMavenDescriptor>false</addMavenDescriptor> <options> <option>@proguard.cfg</option> </options> </configuration> </execution> </executions> </plugin> 

The problem is that I have to point to the jar or folder in which proguard will be launched. In this case, I point to the folder with my classes. The problem is that I have test classes in another folder: test-classes. So, HelloWorld.java will become A.java, and the test code does not know about it and cannot compile.

How do I approach this problem? In my opinion, I still want my test classes to be in a separate folder. And I do not want to configure proguard to store all the files that are used in the tests, as there is code that I want to obfuscate and test.

Thanks in advance!

+4
source share

Source: https://habr.com/ru/post/1499584/


All Articles