maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
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 GMT
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 <code>null</code>
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 <code>null</code> 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 <code>null</code> 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<String> args = new HashSet<String>();
+        args.add( "-t" );
+        args.add( toolchainsFile.getCanonicalPath() );
+
+        assertArgumentsPresent( cli, args );
+    }
     public void testShouldSpecifyCustomPropertyFromRequest()
         throws IOException
     {



Mime
View raw message