Avoid Adding Duplicated JUnit Entries on Classpath #712
+53
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for: #305
Solution:
When running
java-application-with-tests
withmvn -Pnative package
I am getting following results:junitPlatform
andjunitJupiter
versions in the project to1.11.0
and5.11.0
:From the output we see that there are no
5.11.0
entries because this sample sets its own JUnit version through gradle.properties file. With this fix we are giving the advantage to the user's declared version (illustrated in the example above).Possible problem: If we update hardcoded JUnit version to
5.11.0
here (for example to support@FieldSource
annotation - like I did in this PR) and user declared earlier JUnit version in its project (for example5.10.0
) we won't have5.11.0
artifact on the classpath, and therefore we will getNoClassDefFoundError
sinceFieldSource
is not available before5.11.0
version.In that case we can catch and ignore
NoClassDefFoundError
when supporting annotations from newer JUnit versions. The question is: can this harm existing projects if we suddenly remove "duplicates" (same artifacts but with different versions)? Are we currently relying on some JUnit features that are only available from JUnit5.10.0
? cc @melix @sbrannen