Closed Vampire closed 1 year ago
This is not as straight forward as it first appears. Currently, if the junit-5 plugin is added as a dependency for pitest in a maven project, it will work without having to explicitly any other depencies to pitest (e.g jupiter). Without the shaded platform it will fail with a runtime error.
Unfortunately, I can't remember the details of why jupiter gets picked up from the classpath automatically but platform doesn't. Would need some digging before this could be merged.
Hm, ok, this sounds strange. I think I tested it with a Gradle build and it worked fine. But then, it was 3 AM, who knows what I did. :-D
No, I did test with Gradle and there it works perfectly fine.
Only in Maven it does not work.
You add the complete test classpath to the Minions classpath.
Additionally, you check for ClientClasspathPlugin
implementations, but there only add the concrete JAR to the Minion classpath, requiring the plugin to have Maven group as implementation vendor manifest attribute and the Maven artifact as implementation title manifest attribute to identify the jar from the class.
But by this you completely ignore the dependencies those plugins might need which is why you currently need to shade the platform launcher dependency which effectively is the only external dependency. Jupiter is found because it is part of the test classpath which is added to the Minion classpath completely.
I see four (at least) possible ways to mitigate the need for the shading:
ClientClasspathPlugin
that returns a list of necessary dependencies, so they can also be added to the Minion classpathI took the approach 4: hcoles/pitest#1209 So to work with Maven nicely, hcoles/pitest#1209 is a prerequisite for this change.
To function correctly with the SUT version of JUnit 5, the shading needs to be removed and the junit platform dependency needs to be changed to a provided dependency. The maven and gradle plugins then need to be updated to autoadd junit-platform-launcher in the same manner that surefire does.
The maven part of this will be released in pitest 1.14.0. I'm not sure how easy/difficuly this will be for gradle, but the dependency can be added manually until the functionality is available.
As discussed in szpak/gradle-pitest-plugin#337 I adapted the commit message and added a compatibility note to PIT 1.14.0 to the readme, so I guess this PR should now be fine for 1.2.0?
It is present as dependency anyway and even if not it makes no sense to depend on this module without platform being present already anywy and shading it without relocation easily leads to conflicts.