You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/09 15:27:19 UTC

[maven-jdeps-plugin] 07/34: Add support for plugin execution scoped toolchain, as introduced by Maven-3.2.6

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jdeps-plugin.git

commit 7a866fd43d4cb56729735c2a720b95034f9d34c7
Author: Robert Scholte <rf...@apache.org>
AuthorDate: Sat Feb 7 19:49:29 2015 +0000

    Add support for plugin execution scoped toolchain, as introduced by Maven-3.2.6
    
    git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk@1658101 13f79535-47bb-0310-9956-ffa450edef68
---
 .../maven/plugin/jdeps/AbstractJDepsMojo.java      | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java b/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java
index 38cab17..2e3a360 100644
--- a/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java
+++ b/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java
@@ -21,6 +21,10 @@ package org.apache.maven.plugin.jdeps;
 
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
@@ -427,6 +431,47 @@ public abstract class AbstractJDepsMojo
         if ( toolchainManager != null )
         {
             tc = toolchainManager.getToolchainFromBuildContext( "jdk", session );
+
+            getLog().debug( "no toolchains from build context" );
+            if ( tc == null )
+            {
+                // Maven 3.2.6 supports plugin execution scoped Toolchain Support
+                try
+                {
+                    Method getToolchainsMethod =
+                        toolchainManager.getClass().getMethod( "getToolchains", MavenSession.class, String.class,
+                                                               Map.class );
+
+                    List<Toolchain> tcs =
+                        (List<Toolchain>) getToolchainsMethod.invoke( toolchainManager, session, "jdk",
+                                                                      Collections.singletonMap( "version", "[1.8,)" ) );
+
+                    if ( tcs != null && tcs.size() > 0 )
+                    {
+                        tc = tcs.get( 0 );
+                    }
+                }
+                catch ( NoSuchMethodException e )
+                {
+                    // ignore
+                }
+                catch ( SecurityException e )
+                {
+                    // ignore
+                }
+                catch ( IllegalAccessException e )
+                {
+                    // ignore
+                }
+                catch ( IllegalArgumentException e )
+                {
+                    // ignore
+                }
+                catch ( InvocationTargetException e )
+                {
+                    // ignore
+                }
+            }
         }
 
         return tc;

-- 
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.