Return-Path: X-Original-To: apmail-maven-commits-archive@www.apache.org Delivered-To: apmail-maven-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3C4B9D69B for ; Mon, 1 Oct 2012 19:25:57 +0000 (UTC) Received: (qmail 39086 invoked by uid 500); 1 Oct 2012 19:25:55 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 39018 invoked by uid 500); 1 Oct 2012 19:25:55 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 38961 invoked by uid 99); 1 Oct 2012 19:25:54 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2012 19:25:54 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2012 19:25:51 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5A5CF238899C; Mon, 1 Oct 2012 19:25:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1392534 - in /maven/shared/trunk/maven-invoker/src: main/java/org/apache/maven/shared/invoker/ test/java/org/apache/maven/shared/invoker/ Date: Mon, 01 Oct 2012 19:25:07 -0000 To: commits@maven.apache.org From: rfscholte@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121001192507.5A5CF238899C@eris.apache.org> Author: rfscholte Date: Mon Oct 1 19:25:06 2012 New Revision: 1392534 URL: http://svn.apache.org/viewvc?rev=1392534&view=rev Log: [MSHARED-248] Add option for toolchains Modified: maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java Modified: maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java?rev=1392534&r1=1392533&r2=1392534&view=diff ============================================================================== --- maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java (original) +++ maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java Mon Oct 1 19:25:06 2012 @@ -71,6 +71,8 @@ public class DefaultInvocationRequest private File userSettings; private File globalSettings; + + private File toolchains; private String globalChecksumPolicy; @@ -322,6 +324,17 @@ public class DefaultInvocationRequest return this; } + public File getToolchainsFile() + { + return toolchains; + } + + public InvocationRequest setToolchainsFile( File toolchains ) + { + this.toolchains = toolchains; + return this; + } + public String getGlobalChecksumPolicy() { return globalChecksumPolicy; Modified: maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java?rev=1392534&r1=1392533&r2=1392534&view=diff ============================================================================== --- maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java (original) +++ maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java Mon Oct 1 19:25:06 2012 @@ -250,8 +250,17 @@ public interface InvocationRequest * * @return The path to the global settings for the Maven invocation or null to load the global settings * from the default location. + * @since 2.0.12 */ File getGlobalSettingsFile(); + + /** + * Gets the path to the custom toolchains file + * + * @return The path to the custom toolchains file or null to load the toolchains from the default location + * @since 2.0.12 + */ + File getToolchainsFile(); /** * Gets the checksum mode of the Maven invocation. @@ -514,10 +523,20 @@ public interface InvocationRequest * @param globalSettings The path to the global settings for the Maven invocation, may be null to load * the global settings from the default location. * @return This invocation request. + * @since 2.0.12 */ InvocationRequest setGlobalSettingsFile( File globalSettings ); /** + * Sets the alternate path for the user toolchains file + * Equivalent of {@code -t} or {@code --toolchains} + * + * @param toolchains the alternate path for the user toolchains file + * @return This invocation request + * @since 2.0.12 + */ + InvocationRequest setToolchainsFile( File toolchains ); + /** * Sets the checksum mode of the Maven invocation. * * @param globalChecksumPolicy The checksum mode, must be one of {@link #CHECKSUM_POLICY_WARN} and Modified: maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java?rev=1392534&r1=1392533&r2=1392534&view=diff ============================================================================== --- maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java (original) +++ maven/shared/trunk/maven-invoker/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java Mon Oct 1 19:25:06 2012 @@ -94,6 +94,8 @@ public class MavenCommandLineBuilder setSettingsLocation( request, cli ); + setToolchainsLocation( request, cli ); + setProperties( request, cli ); setProfiles( request, cli ); @@ -101,7 +103,7 @@ public class MavenCommandLineBuilder setGoals( request, cli ); setThreads( request, cli ); - + return cli; } @@ -167,6 +169,28 @@ public class MavenCommandLineBuilder } } + + protected void setToolchainsLocation( InvocationRequest request, Commandline cli ) + { + File toolchainsFile = request.getToolchainsFile(); + + if ( toolchainsFile != null ) + { + try + { + File canSet = toolchainsFile.getCanonicalFile(); + toolchainsFile = canSet; + } + catch ( IOException e ) + { + logger.debug( "Failed to canonicalize toolchains path: " + toolchainsFile.getAbsolutePath() + + ". Using as-is.", e ); + } + + cli.createArg().setValue( "-t" ); + cli.createArg().setValue( toolchainsFile.getPath() ); + } + } protected void setShellEnvironment( InvocationRequest request, Commandline cli ) throws CommandLineConfigurationException Modified: maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java?rev=1392534&r1=1392533&r2=1392534&view=diff ============================================================================== --- maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java (original) +++ maven/shared/trunk/maven-invoker/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java Mon Oct 1 19:25:06 2012 @@ -839,6 +839,33 @@ public class MavenCommandLineBuilderTest assertArgumentsPresent( cli, args ); } + public void testShouldSpecifyCustomToolchainsLocationFromRequest() + throws Exception + { + logTestStart(); + + File tmpDir = getTempDir(); + File base = new File( tmpDir, "invoker-tests" ); + + toDelete.add( base ); + + File projectDir = new File( base, "custom-toolchains" ).getCanonicalFile(); + + projectDir.mkdirs(); + + File toolchainsFile = createDummyFile( projectDir, "toolchains.xml" ); + + Commandline cli = new Commandline(); + + TestCommandLineBuilder tcb = new TestCommandLineBuilder(); + tcb.setToolchainsLocation( newRequest().setToolchainsFile( toolchainsFile ), cli ); + + Set args = new HashSet(); + args.add( "-t" ); + args.add( toolchainsFile.getCanonicalPath() ); + + assertArgumentsPresent( cli, args ); + } public void testShouldSpecifyCustomPropertyFromRequest() throws IOException {