akomakom commented on a change in pull request #285:
URL: https://github.com/apache/maven-surefire/pull/285#discussion_r414604856



##########
File path: 
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
##########
@@ -948,6 +948,29 @@ protected final PluginConsoleLogger getConsoleLogger()
         return consoleLogger;
     }
 
+    private static <T extends ToolchainManager> Toolchain 
getToolchainMaven33x( Class<T> toolchainManagerType,
+                                                                               
 T toolchainManager,
+                                                                               
 MavenSession session,
+                                                                               
 Map<String, String> toolchainArgs )
+        throws MojoFailureException
+    {
+        Method getToolchainsMethod =
+            tryGetMethod( toolchainManagerType, "getToolchains", 
MavenSession.class, String.class, Map.class );
+        if ( getToolchainsMethod != null )
+        {
+            //noinspection unchecked
+            List<Toolchain> tcs = (List<Toolchain>) invokeMethodWithArray( 
toolchainManager,
+                getToolchainsMethod, session, "jdk", toolchainArgs );
+            if ( tcs.isEmpty() )
+            {
+                throw new MojoFailureException(
+                    "Requested toolchain specification did not match any 
configured toolchain: " + toolchainArgs );
+            }
+            return tcs.get( 0 );
+        }
+        return null;

Review comment:
       Done

##########
File path: 
maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
##########
@@ -956,21 +979,7 @@ private Toolchain getToolchain() throws 
MojoFailureException
 
         if ( getJdkToolchain() != null )
         {
-            Method getToolchainsMethod = tryGetMethod( ToolchainManager.class, 
"getToolchains",
-                MavenSession.class, String.class, Map.class );
-            if ( getToolchainsMethod != null )
-            {
-                //noinspection unchecked
-                List<Toolchain> tcs = (List<Toolchain>) invokeMethodWithArray( 
getToolchainManager(),
-                    getToolchainsMethod, getSession(), "jdk", 
getJdkToolchain() );
-                if ( tcs.isEmpty() )
-                {
-                    throw new MojoFailureException(
-                        "Requested toolchain specification did not match any 
configured toolchain: "
-                            + getJdkToolchain() );
-                }
-                tc = tcs.get( 0 );
-            }
+            tc = getToolchainMaven33x( ToolchainManager.class, 
getToolchainManager(), getSession(), getJdkToolchain() );

Review comment:
       Done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to