Search code examples
androidmavenpitest

Exclude provided dependency from classpath when running PIT


I'd like to use the PIT (pitest.org) plugin on an Android project. I'm using the Android Maven plugin and have a fairly standard POM. The Android JAR is included by Maven with a provided scope and includes actual sources, not the stubbed JAR from the SDK.

Running PIT from the command line via the Maven plugin fails:

[ERROR] Failed to execute goal org.pitest:pitest-maven:1.1.3:mutationCoverage (default-cli) on project easystat: Executi
on default-cli of goal org.pitest:pitest-maven:1.1.3:mutationCoverage failed: Coverage generation slave exited abnormall
y!
[ERROR]
[ERROR] Please copy and paste the information and the complete stacktrace below when reporting an issue
[ERROR] VM : Java HotSpot(TM) 64-Bit Server VM
[ERROR] Vendor : Oracle Corporation
[ERROR] Version : 25.25-b02
[ERROR] Uptime : 3804
[ERROR] Input ->
[ERROR] 1 : -Dclassworlds.conf=C:\Users\Tom\maven\bin\..\bin\m2.conf
[ERROR] 2 : -Dmaven.home=C:\Users\Tom\maven\bin\..
[ERROR] BootClassPathSupported : true
[ERROR]
[ERROR]
[ERROR] Please copy and paste the information and the complete stacktrace below when reporting an issue
[ERROR] VM : Java HotSpot(TM) 64-Bit Server VM
[ERROR] Vendor : Oracle Corporation
[ERROR] Version : 25.25-b02
[ERROR] Uptime : 3804
[ERROR] Input ->
[ERROR] 1 : -Dclassworlds.conf=C:\Users\Tom\maven\bin\..\bin\m2.conf
[ERROR] 2 : -Dmaven.home=C:\Users\Tom\maven\bin\..
[ERROR] BootClassPathSupported : true
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.pitest:pitest-maven:1.1.3:mutationCov
erage (default-cli) on project easystat: Execution default-cli of goal org.pitest:pitest-maven:1.1.3:mutationCoverage fa
iled: Coverage generation slave exited abnormally!

Please copy and paste the information and the complete stacktrace below when reporting an issue
VM : Java HotSpot(TM) 64-Bit Server VM
Vendor : Oracle Corporation
Version : 25.25-b02
Uptime : 3804
Input ->
 1 : -Dclassworlds.conf=C:\Users\Tom\maven\bin\..\bin\m2.conf
 2 : -Dmaven.home=C:\Users\Tom\maven\bin\..
BootClassPathSupported : true

Some previous discussion on Google Groups suggested that including an older version of JUnit could cause an error like this, and it looks like the Android JAR includes one of the 3.x JUnit libraries (thanks, Android team...). To confirm or deny this hunch, I'd like to exclude the Android JAR from PIT's classpath, since I already do during the Surefire test phase anyway, but I don't see any option to do so.

Is there a way to exclude a provided dependency from PIT, without having to change the scope of that dependency?


Solution

  • PIT doesn't currently provide a way to filter out dependencies, it will use all dependencies from the project at test scope.

    This would be a sensible feature to add - feel free to create an issue.

    You might be able to work around the issue by placing junit4 before the android jar in your classpath/dependencies.