maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] sormuras commented on a change in pull request #196: [SUREFIRE-1585] [WIP] Resolve missing artifact
Date Thu, 25 Oct 2018 07:06:43 GMT
sormuras commented on a change in pull request #196: [SUREFIRE-1585] [WIP] Resolve missing
artifact
URL: https://github.com/apache/maven-surefire/pull/196#discussion_r228054718
 
 

 ##########
 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:
   Not sure about this one... as the version numbers we do inject are those we extract from
the project test class-path artifacts. Thus, the version will be aligned by default.
   
   Regarding transitive dependencies... well, yes. No. We shouldn't try to fix those potential
version mismatches here. Too much hidden magic inside a magic feature. Instead let the users
configure the right dependencies in their pom in the first place.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message