Tibor17 commented on a change in pull request #196: [SUREFIRE-1585] [WIP]
Resolve missing artifact
URL: https://github.com/apache/maven-surefire/pull/196#discussion_r228046613
##########
File path:
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/TestClassPath.java
##########
@@ -87,15 +88,40 @@ private void addMissingArtifacts( Set<Artifact>
providerArtifacts )
// TODO Check for actual SurefireProvider -- the following only
applies for when
//
'org.apache.maven.surefire.junitplatform.JUnitPlatformProvider' is active.
- // TODO Add missing 'junit-jupiter-engine' to test runtime
- // Artifact junitJupiterApi = findArtifact(
"org.junit.jupiter:junit-jupiter-api", artifacts );
- // Artifact junitJupiterEngine =
- // findArtifact( "org.junit.jupiter:junit-jupiter-engine",
artifacts, providerArtifacts );
- // if ( junitJupiterApi != null && junitJupiterEngine == null )
- // {
- // [artifacts | providerArtifacts]
- // .add( "org.junit.jupiter:junit-jupiter-engine:" +
junitJupiterApi.getVersion() );
- // }
+ if ( mojo == null )
+ {
+ // mojo.getLog().warn( "Can't resolve missing artifacts when mojo
is not set." );
+ return;
+ }
+
+ // Add missing 'junit-jupiter-engine' to test runtime
+ Map<String, Artifact> artifactMap = mojo.getProjectArtifactMap();
+ Artifact junitJupiterApi = artifactMap.get(
"org.junit.jupiter:junit-jupiter-api" );
+ Artifact junitJupiterEngine = artifactMap.get(
"org.junit.jupiter:junit-jupiter-engine" );
+ if ( junitJupiterApi != null && junitJupiterEngine == null )
+ {
+ junitJupiterEngine = new DefaultArtifact(
+ "org.junit.jupiter",
+ "junit-jupiter-engine",
+ junitJupiterApi.getVersionRange(),
+ "test",
+ "jar",
+ "",
+ junitJupiterApi.getArtifactHandler()
+ );
+ @SuppressWarnings( "unchecked" )
+ Set<Artifact> resolvedArtifacts = mojo.resolveArtifact( null,
junitJupiterEngine ).getArtifacts();
+ providerArtifacts.addAll( resolvedArtifacts );
Review comment:
This is a Set. Some artifacts won't be added if they are already in the Set.
Should we override them anyway if higher version is going to be added?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services