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 and align "JUnit 5" artifacts
Date Sat, 10 Nov 2018 23:49:53 GMT
sormuras commented on a change in pull request #196: [SUREFIRE-1585] [WIP] Resolve missing
and align "JUnit 5" artifacts
URL: https://github.com/apache/maven-surefire/pull/196#discussion_r232469829
 
 

 ##########
 File path: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
 ##########
 @@ -2846,8 +2849,92 @@ public void addProviderProperties()
         @Nonnull
         public Set<Artifact> getProviderClasspath()
         {
+            String provider = "surefire-junit-platform";
             String version = surefireBooterArtifact.getBaseVersion();
-            return dependencyResolver.getProviderClasspath( "surefire-junit-platform", version
);
+            Set<Artifact> providerArtifacts = dependencyResolver.getProviderClasspath(
provider, version );
+            alignJUnitPlatformVersion( providerArtifacts );
+            resolveJUnitJupiterEngine( providerArtifacts );
+            resolveJUnitVintageEngine( providerArtifacts );
+            return providerArtifacts;
+        }
+
+        private void resolveJUnitJupiterEngine( Set<Artifact> providerArtifacts )
+        {
+            Artifact junitJupiterApi = getProjectArtifactMap().get( "org.junit.jupiter:junit-jupiter-api"
);
+            if ( junitJupiterApi == null ) // no api, no engine
+            {
+                return;
+            }
+            Artifact junitJupiterEngine = getProjectArtifactMap().get( "org.junit.jupiter:junit-jupiter-engine"
);
+            if ( junitJupiterEngine != null ) // engine already resolved by project
+            {
+                return;
+            }
+            // resolve "junit-jupiter-engine" and its transitive dependencies
+            String version = junitJupiterApi.getBaseVersion();
+            resolve( providerArtifacts, "org.junit.jupiter", "junit-jupiter-engine", version
);
+        }
+
+        private void resolveJUnitVintageEngine( Set<Artifact> providerArtifacts )
+        {
+            Artifact junit = getProjectArtifactMap().get( "junit:junit" );
+            if ( junit == null || !junit.getBaseVersion().equals( "4.12" ) ) // no or wrong
"junit", no engine
+            {
+                return;
+            }
+            Artifact junitVintageEngine = getProjectArtifactMap().get( "org.junit.vintage:junit-vintage-engine"
);
+            if ( junitVintageEngine != null ) // engine already resolved by project
+            {
+                return;
+            }
+            // resolve "junit-vintage-engine" and its transitive dependencies
+            // heuristic: from Platform "x.y.z" to Vintage "5" + ".y.z"
+            String junitVintageVersion = "5" + junitPlatformArtifact.getBaseVersion().substring(
1 );
+            resolve( providerArtifacts, "org.junit.vintage", "junit-vintage-engine", junitVintageVersion
);
+        }
+
+        private void alignJUnitPlatformVersion( Set<Artifact> providerArtifacts )
+        {
+            Map<String, Artifact> providerArtifactMap = new HashMap<String, Artifact>();
+            for ( Artifact artifact : providerArtifacts )
+            {
+                String key = artifact.getGroupId() + ":" + artifact.getArtifactId();
+                providerArtifactMap.put( key, artifact );
+            }
+            Artifact defaultLauncher = providerArtifactMap.get( "org.junit.platform:junit-platform-launcher"
);
+            logDebugOrCliShowErrors( "JUnit Platform Artifact: " + junitPlatformArtifact
);
+            logDebugOrCliShowErrors( "JUnit Platform Launcher: " + defaultLauncher );
+            if ( junitPlatformArtifact.getVersion().equals( defaultLauncher.getVersion()
) )
+            {
+                logDebugOrCliShowErrors( "JUnit Platform versions are equal - proceeding
anyway... " );
 
 Review comment:
   Here should be a `return;` statement -- but then resulting classpath order is not matching
in the integration tests.

----------------------------------------------------------------
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