Author: rfscholte Date: Sat Feb 7 19:49:29 2015 New Revision: 1658101 URL: http://svn.apache.org/r1658101 Log: Add support for plugin execution scoped toolchain, as introduced by Maven-3.2.6
Modified: maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java Modified: maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java?rev=1658101&r1=1658100&r2=1658101&view=diff ============================================================================== --- maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java (original) +++ maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java Sat Feb 7 19:49:29 2015 @@ -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;