diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java
new file mode 100644
index 0000000000..45afabe76f
--- /dev/null
+++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng3714ToolchainsCliOptionTest.java
@@ -0,0 +1,79 @@
+package org.apache.maven.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * This is a test set for MNG-3714.
+ *
+ * @author Brett Porter
+ * @version $Id: MavenITmng0557UserSettingsCliOptionTest.java 744504 2009-02-14 14:49:27Z brett $
+ */
+public class MavenITmng3714ToolchainsCliOptionTest
+ extends AbstractMavenIntegrationTestCase
+{
+ public MavenITmng3714ToolchainsCliOptionTest()
+ {
+ super( "[2.1.0,)" );
+ }
+
+ /**
+ * Test --toolchains CLI option
+ */
+ public void testitMNG3714()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3714" );
+ File javaHome = new File( testDir, "javaHome" );
+ javaHome.mkdirs();
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ Properties properties = verifier.newDefaultFilterProperties();
+ properties.setProperty( "@javaHome@", javaHome.getAbsolutePath() );
+
+ verifier.filterFile( "toolchains.xml", "toolchains.xml", "UTF-8", properties );
+
+ verifier.setAutoclean( false );
+ verifier.deleteDirectory( "target" );
+ List cliOptions = new ArrayList();
+ cliOptions.add( "--toolchains toolchains.xml" );
+ verifier.setCliOptions( cliOptions );
+ verifier.executeGoal( "org.apache.maven.its.plugins:maven-it-plugin-toolchain:toolchain" );
+ verifier.verifyErrorFreeLog();
+ verifier.resetStreams();
+
+ verifier.assertFilePresent( "target/toolchains.properties" );
+ Properties results = verifier.loadProperties( "target/toolchains.properties" );
+ String tool = results.getProperty( "tool.1" );
+ if ( tool.endsWith( ".exe" ) )
+ {
+ tool = tool.substring( 0, tool.length() - 4 );
+ }
+ assertEquals( new File( javaHome, "bin/javac" ).getAbsolutePath(), tool );
+ }
+
+}
diff --git a/its/core-it-suite/src/test/resources/bootstrap/pom.xml b/its/core-it-suite/src/test/resources/bootstrap/pom.xml
index 5d3f6e6239..97278f63c0 100644
--- a/its/core-it-suite/src/test/resources/bootstrap/pom.xml
+++ b/its/core-it-suite/src/test/resources/bootstrap/pom.xml
@@ -230,6 +230,12 @@ under the License.
${itPluginVersion}
runtime
+
+ org.apache.maven.its.plugins
+ maven-it-plugin-toolchain
+ ${itPluginVersion}
+ runtime
+
org.apache.maven.its.plugins
maven-it-plugin-uses-properties
diff --git a/its/core-it-suite/src/test/resources/mng-3714/pom.xml b/its/core-it-suite/src/test/resources/mng-3714/pom.xml
new file mode 100644
index 0000000000..f17ec2e53c
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-3714/pom.xml
@@ -0,0 +1,17 @@
+
+ 4.0.0
+ Maven Integration Test :: MNG-3714
+ org.apache.maven.its.mng3714
+ maven-it-mng3714
+ Test --toolchains CLI option
+ 1.0-SNAPSHOT
+
+
+
+ org.apache.maven.its.plugins
+ maven-it-plugin-toolchain
+ 2.1-SNAPSHOT
+
+
+
+
diff --git a/its/core-it-suite/src/test/resources/mng-3714/toolchains.xml b/its/core-it-suite/src/test/resources/mng-3714/toolchains.xml
new file mode 100644
index 0000000000..93f9833040
--- /dev/null
+++ b/its/core-it-suite/src/test/resources/mng-3714/toolchains.xml
@@ -0,0 +1,16 @@
+
+
+
+
+ jdk
+
+ 1.5
+ sun
+ default
+
+
+ @javaHome@
+
+
+
+
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml
new file mode 100644
index 0000000000..8f9c03c02c
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/pom.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+ 4.0.0
+
+
+ maven-it-plugins
+ org.apache.maven.its.plugins
+ 2.1-SNAPSHOT
+
+
+ maven-it-plugin-toolchain
+ maven-plugin
+
+ Maven Integration Test Plugin :: Toolchain
+
+
+
+ org.apache.maven
+ maven-plugin-api
+ 2.0
+
+
+ org.apache.maven
+ maven-toolchain
+ 2.0.10
+
+
+
diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
new file mode 100644
index 0000000000..df2f7c19a5
--- /dev/null
+++ b/its/core-it-support/core-it-plugins/maven-it-plugin-toolchain/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
@@ -0,0 +1,111 @@
+package org.apache.maven.plugin.coreit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.toolchain.MisconfiguredToolchainException;
+import org.apache.maven.toolchain.ToolchainManagerPrivate;
+import org.apache.maven.toolchain.ToolchainPrivate;
+import org.codehaus.plexus.util.IOUtil;
+
+/**
+ * @goal toolchain
+ * @phase validate
+ */
+public class CoreItMojo
+ extends AbstractMojo
+{
+ /**
+ * @component
+ */
+ private ToolchainManagerPrivate toolchainManager;
+
+ /**
+ * The path to the output file for the properties.
+ *
+ * @parameter expression="${toolchain.outputFile}" default-value="${project.build.directory}/toolchains.properties"
+ */
+ private File outputFile;
+
+ /**
+ * @parameter default-value="jdk"
+ */
+ private String type;
+
+ /**
+ * @parameter default-value="javac"
+ */
+ private String tool;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ ToolchainPrivate[] tcs;
+ try
+ {
+ tcs = toolchainManager.getToolchainsForType( type );
+ }
+ catch ( MisconfiguredToolchainException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+
+ getLog().info( "Toolchain in compiler-plugin: " + Arrays.asList( tcs ) );
+
+ Properties properties = new Properties();
+
+ int count = 1;
+ for ( Iterator i = Arrays.asList( tcs ).iterator(); i.hasNext(); count++ )
+ {
+ ToolchainPrivate toolchain = (ToolchainPrivate) i.next();
+
+ String foundTool = toolchain.findTool( tool );
+ if ( foundTool != null )
+ {
+ properties.setProperty( "tool." + count, foundTool );
+ }
+ }
+
+ OutputStream out = null;
+ try
+ {
+ outputFile.getParentFile().mkdirs();
+ out = new FileOutputStream( outputFile );
+ properties.store( out, "MAVEN-CORE-IT-LOG" );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( out );
+ }
+ }
+}
diff --git a/its/core-it-support/core-it-plugins/pom.xml b/its/core-it-support/core-it-plugins/pom.xml
index 48c1fd7792..bd34ce1256 100644
--- a/its/core-it-support/core-it-plugins/pom.xml
+++ b/its/core-it-support/core-it-plugins/pom.xml
@@ -51,6 +51,7 @@ under the License.
maven-it-plugin-project-interpolation
maven-it-plugin-setter
maven-it-plugin-site
+ maven-it-plugin-toolchain
maven-it-plugin-touch
maven-it-plugin-uses-properties
maven-it-plugin-uses-wagon