I run into problems at Maven compile when using JMockit together with JUnit and Android:
[INFO] UNEXPECTED TOP-LEVEL EXCEPTION: [INFO] java.lang.IllegalArgumentException: already added: Ljunit/framework/TestResult$1;
At least JUnit and JMockit contain TestResult, so I thought about using the shade plugin to exclude these files:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>com.googlecode.jmockit:jmockit</artifact>
<excludes>
<exclude>junit/framework/**</exclude>
</excludes>
</filter>
<filter>
<artifact>junit:junit</artifact>
<excludes>
<exclude>junit/framework/**</exclude>
</excludes>
</filter>
</filters>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
Unfortunately I still get these errors. Any ideas what's wrong here or did I misunderstand what this plugin is about? Or maybe you know a better solution to get rid of multiple package clashes with Maven?
UPDATE
(Meanwhile I unpacked and removed the conflicting dependencies manually from the jars and repacked all packages into an uber jar and installed it into the local repository. This works. But I still would be interested in a more professional solution)