maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r1126825 [2/2] - in /maven/maven-3/branches/mirror-group-routing: maven-core/src/main/java/org/apache/maven/ maven-core/src/main/java/org/apache/maven/execution/ maven-embedder/src/main/java/org/apache/maven/cli/
Date Tue, 24 May 2011 02:16:50 GMT
Modified: maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewvc/maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java?rev=1126825&r1=1126824&r2=1126825&view=diff
==============================================================================
--- maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
(original)
+++ maven/maven-3/branches/mirror-group-routing/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
Tue May 24 02:16:50 2011
@@ -19,17 +19,6 @@ package org.apache.maven.cli;
  * under the License.
  */
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.UnrecognizedOptionException;
@@ -50,6 +39,10 @@ import org.apache.maven.lifecycle.intern
 import org.apache.maven.model.building.ModelProcessor;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.properties.internal.EnvironmentUtils;
+import org.apache.maven.repository.mirror.configuration.FileMirrorRouterConfigSource;
+import org.apache.maven.repository.mirror.configuration.MirrorRouterConfigBuilder;
+import org.apache.maven.repository.mirror.configuration.MirrorRouterConfiguration;
+import org.apache.maven.repository.mirror.configuration.MirrorRouterConfigurationException;
 import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
 import org.apache.maven.settings.building.SettingsBuilder;
 import org.apache.maven.settings.building.SettingsBuildingRequest;
@@ -72,6 +65,17 @@ import org.sonatype.plexus.components.se
 import org.sonatype.plexus.components.sec.dispatcher.SecUtil;
 import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
 // TODO: push all common bits back to plexus cli and prepare for transition to Guice. We
don't need 50 ways to make CLIs
 
 /**
@@ -94,12 +98,12 @@ public class MavenCli
         new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" )
), "conf/settings.xml" );
 
     public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome,
"toolchains.xml" );
-    
+
     public static final File DEFAULT_USER_EXT_CONF_DIR = new File( userMavenConfigurationHome,
"conf" );
 
     private static final String EXT_CLASS_PATH = "maven.ext.class.path";
 
-    private ClassWorld classWorld;
+    private final ClassWorld classWorld;
 
     // Per-instance container supports fast embedded execution of core ITs
     private DefaultPlexusContainer container;
@@ -118,43 +122,46 @@ public class MavenCli
 
     private DefaultSecDispatcher dispatcher;
 
+    private MirrorRouterConfigBuilder routerConfBuilder;
+
     public MavenCli()
     {
         this( null );
     }
 
     // This supports painless invocation by the Verifier during embedded execution of the
core ITs
-    public MavenCli( ClassWorld classWorld )
+    public MavenCli( final ClassWorld classWorld )
     {
         this.classWorld = classWorld;
     }
 
-    public static void main( String[] args )
+    public static void main( final String[] args )
     {
-        int result = main( args, null );
+        final int result = main( args, null );
 
         System.exit( result );
     }
 
     /** @noinspection ConfusingMainMethod */
-    public static int main( String[] args, ClassWorld classWorld )
+    public static int main( final String[] args, final ClassWorld classWorld )
     {
-        MavenCli cli = new MavenCli();
+        final MavenCli cli = new MavenCli();
         return cli.doMain( new CliRequest( args, classWorld ) );
     }
 
     // TODO: need to externalize CliRequest
-    public static int doMain( String[] args, ClassWorld classWorld )
+    public static int doMain( final String[] args, final ClassWorld classWorld )
     {
-        MavenCli cli = new MavenCli();
+        final MavenCli cli = new MavenCli();
         return cli.doMain( new CliRequest( args, classWorld ) );
     }
 
     // This supports painless invocation by the Verifier during embedded execution of the
core ITs
-    public int doMain( String[] args, String workingDirectory, PrintStream stdout, PrintStream
stderr )
+    public int doMain( final String[] args, final String workingDirectory, final PrintStream
stdout,
+                       final PrintStream stderr )
     {
-        PrintStream oldout = System.out;
-        PrintStream olderr = System.err;
+        final PrintStream oldout = System.out;
+        final PrintStream olderr = System.err;
 
         try
         {
@@ -167,7 +174,7 @@ public class MavenCli
                 System.setErr( stderr );
             }
 
-            CliRequest cliRequest = new CliRequest( args, classWorld );
+            final CliRequest cliRequest = new CliRequest( args, classWorld );
             cliRequest.workingDirectory = workingDirectory;
 
             return doMain( cliRequest );
@@ -180,7 +187,7 @@ public class MavenCli
     }
 
     // TODO: need to externalize CliRequest
-    public int doMain( CliRequest cliRequest )
+    public int doMain( final CliRequest cliRequest )
     {
         try
         {
@@ -197,22 +204,22 @@ public class MavenCli
             encryption( cliRequest );
             return execute( cliRequest );
         }
-        catch( ExitException e )
+        catch ( final ExitException e )
         {
             return e.exitCode;
         }
-        catch ( UnrecognizedOptionException e )
+        catch ( final UnrecognizedOptionException e )
         {
             // pure user error, suppress stack trace
             return 1;
         }
-        catch ( BuildAbort e )
+        catch ( final BuildAbort e )
         {
             CLIReportingUtils.showError( logger, "ABORTED", e, cliRequest.showErrors );
 
             return 2;
         }
-        catch ( Exception e )
+        catch ( final Exception e )
         {
             CLIReportingUtils.showError( logger, "Error executing Maven.", e, cliRequest.showErrors
);
 
@@ -227,7 +234,7 @@ public class MavenCli
         }
     }
 
-    private void initialize( CliRequest cliRequest )
+    private void initialize( final CliRequest cliRequest )
     {
         if ( cliRequest.workingDirectory == null )
         {
@@ -238,7 +245,7 @@ public class MavenCli
         // Make sure the Maven home directory is an absolute path to save us from confusion
with say drive-relative
         // Windows paths.
         //
-        String mavenHome = System.getProperty( "maven.home" );
+        final String mavenHome = System.getProperty( "maven.home" );
 
         if ( mavenHome != null )
         {
@@ -249,7 +256,7 @@ public class MavenCli
     //
     // Logging needs to be handled in a standard way at the container level.
     //
-    private void logging( CliRequest cliRequest )
+    private void logging( final CliRequest cliRequest )
     {
         cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG );
         cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption(
CLIManager.QUIET );
@@ -284,7 +291,7 @@ public class MavenCli
                 System.setOut( cliRequest.fileStream );
                 System.setErr( cliRequest.fileStream );
             }
-            catch ( FileNotFoundException e )
+            catch ( final FileNotFoundException e )
             {
                 System.err.println( e );
             }
@@ -294,16 +301,16 @@ public class MavenCli
     //
     // Every bit of information taken from the CLI should be processed here.
     //
-    private void cli( CliRequest cliRequest )
+    private void cli( final CliRequest cliRequest )
         throws Exception
     {
-        CLIManager cliManager = new CLIManager();
+        final CLIManager cliManager = new CLIManager();
 
         try
         {
             cliRequest.commandLine = cliManager.parse( cliRequest.args );
         }
-        catch ( ParseException e )
+        catch ( final ParseException e )
         {
             System.err.println( "Unable to parse command line options: " + e.getMessage()
);
             cliManager.displayHelp( System.out );
@@ -325,7 +332,7 @@ public class MavenCli
         }
     }
 
-    private void version( CliRequest cliRequest )
+    private void version( final CliRequest cliRequest )
     {
         if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION
) )
         {
@@ -333,7 +340,7 @@ public class MavenCli
         }
     }
 
-    private void commands( CliRequest cliRequest )
+    private void commands( final CliRequest cliRequest )
     {
         if ( cliRequest.showErrors )
         {
@@ -350,12 +357,12 @@ public class MavenCli
         }
     }
 
-    private void properties( CliRequest cliRequest )
+    private void properties( final CliRequest cliRequest )
     {
         populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties
);
     }
 
-    private void container( CliRequest cliRequest )
+    private void container( final CliRequest cliRequest )
         throws Exception
     {
         if ( cliRequest.classWorld == null )
@@ -369,10 +376,10 @@ public class MavenCli
         {
             logger = setupLogger( cliRequest );
 
-            ContainerConfiguration cc = new DefaultContainerConfiguration()
-                .setClassWorld( cliRequest.classWorld )
-                .setRealm( setupContainerRealm( cliRequest ) )
-                .setName( "maven" );
+            final ContainerConfiguration cc =
+                new DefaultContainerConfiguration().setClassWorld( cliRequest.classWorld
)
+                                                   .setRealm( setupContainerRealm( cliRequest
) )
+                                                   .setName( "maven" );
 
             container = new DefaultPlexusContainer( cc );
 
@@ -395,8 +402,8 @@ public class MavenCli
 
         eventSpyDispatcher = container.lookup( EventSpyDispatcher.class );
 
-        DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext();
-        Map<String, Object> data = eventSpyContext.getData();
+        final DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext();
+        final Map<String, Object> data = eventSpyContext.getData();
         data.put( "plexus", container );
         data.put( "workingDirectory", cliRequest.workingDirectory );
         data.put( "systemProperties", cliRequest.systemProperties );
@@ -411,6 +418,8 @@ public class MavenCli
 
         executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class
);
 
+        routerConfBuilder = container.lookup( MirrorRouterConfigBuilder.class );
+
         modelProcessor = createModelProcessor( container );
 
         settingsBuilder = container.lookup( SettingsBuilder.class );
@@ -418,9 +427,9 @@ public class MavenCli
         dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven"
);
     }
 
-    private PrintStreamLogger setupLogger( CliRequest cliRequest )
+    private PrintStreamLogger setupLogger( final CliRequest cliRequest )
     {
-        PrintStreamLogger logger = new PrintStreamLogger( new PrintStreamLogger.Provider()
+        final PrintStreamLogger logger = new PrintStreamLogger( new PrintStreamLogger.Provider()
         {
             public PrintStream getStream()
             {
@@ -433,7 +442,7 @@ public class MavenCli
         return logger;
     }
 
-    private ClassRealm setupContainerRealm( CliRequest cliRequest )
+    private ClassRealm setupContainerRealm( final CliRequest cliRequest )
         throws Exception
     {
         ClassRealm containerRealm = null;
@@ -446,7 +455,7 @@ public class MavenCli
 
         if ( StringUtils.isNotEmpty( extClassPath ) )
         {
-            String[] jars = StringUtils.split( extClassPath, File.pathSeparator );
+            final String[] jars = StringUtils.split( extClassPath, File.pathSeparator );
 
             if ( jars.length > 0 )
             {
@@ -456,13 +465,13 @@ public class MavenCli
                     coreRealm = (ClassRealm) cliRequest.classWorld.getRealms().iterator().next();
                 }
 
-                ClassRealm extRealm = cliRequest.classWorld.newRealm( "maven.ext", null );
+                final ClassRealm extRealm = cliRequest.classWorld.newRealm( "maven.ext",
null );
 
                 logger.debug( "Populating class realm " + extRealm.getId() );
 
-                for ( String jar : jars )
+                for ( final String jar : jars )
                 {
-                    File file = resolveFile( new File( jar ), cliRequest.workingDirectory
);
+                    final File file = resolveFile( new File( jar ), cliRequest.workingDirectory
);
 
                     logger.debug( "  Included " + file );
 
@@ -478,21 +487,21 @@ public class MavenCli
         return containerRealm;
     }
 
-    protected void customizeContainer( PlexusContainer container )
+    protected void customizeContainer( final PlexusContainer container )
     {
     }
 
     //
     // This should probably be a separate tool and not be baked into Maven.
     //
-    private void encryption( CliRequest cliRequest )
+    private void encryption( final CliRequest cliRequest )
         throws Exception
     {
         if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_MASTER_PASSWORD ) )
         {
-            String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD
);
+            final String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD
);
 
-            DefaultPlexusCipher cipher = new DefaultPlexusCipher();
+            final DefaultPlexusCipher cipher = new DefaultPlexusCipher();
 
             System.out.println( cipher.encryptAndDecorate( passwd, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION
) );
 
@@ -500,7 +509,7 @@ public class MavenCli
         }
         else if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_PASSWORD ) )
         {
-            String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD
);
+            final String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD
);
 
             String configurationFile = dispatcher.getConfigurationFile();
 
@@ -509,11 +518,12 @@ public class MavenCli
                 configurationFile = System.getProperty( "user.home" ) + configurationFile.substring(
1 );
             }
 
-            String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION,
configurationFile );
+            final String file =
+                System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile
);
 
             String master = null;
 
-            SettingsSecurity sec = SecUtil.read( file, true );
+            final SettingsSecurity sec = SecUtil.read( file, true );
             if ( sec != null )
             {
                 master = sec.getMaster();
@@ -524,19 +534,20 @@ public class MavenCli
                 throw new IllegalStateException( "Master password is not set in the setting
security file: " + file );
             }
 
-            DefaultPlexusCipher cipher = new DefaultPlexusCipher();
-            String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION
);
+            final DefaultPlexusCipher cipher = new DefaultPlexusCipher();
+            final String masterPasswd =
+                cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION
);
             System.out.println( cipher.encryptAndDecorate( passwd, masterPasswd ) );
 
             throw new ExitException( 0 );
         }
     }
 
-    private int execute( CliRequest cliRequest )
+    private int execute( final CliRequest cliRequest )
     {
         eventSpyDispatcher.onEvent( cliRequest.request );
 
-        MavenExecutionResult result = maven.execute( cliRequest.request );
+        final MavenExecutionResult result = maven.execute( cliRequest.request );
 
         eventSpyDispatcher.onEvent( result );
 
@@ -544,15 +555,15 @@ public class MavenCli
 
         if ( result.hasExceptions() )
         {
-            ExceptionHandler handler = new DefaultExceptionHandler();
+            final ExceptionHandler handler = new DefaultExceptionHandler();
 
-            Map<String, String> references = new LinkedHashMap<String, String>();
+            final Map<String, String> references = new LinkedHashMap<String, String>();
 
             MavenProject project = null;
 
-            for ( Throwable exception : result.getExceptions() )
+            for ( final Throwable exception : result.getExceptions() )
             {
-                ExceptionSummary summary = handler.handleException( exception );
+                final ExceptionSummary summary = handler.handleException( exception );
 
                 logSummary( summary, references, "", cliRequest.showErrors );
 
@@ -577,9 +588,9 @@ public class MavenCli
             {
                 logger.error( "" );
                 logger.error( "For more information about the errors and possible solutions"
-                              + ", please read the following articles:" );
+                                + ", please read the following articles:" );
 
-                for ( Map.Entry<String, String> entry : references.entrySet() )
+                for ( final Map.Entry<String, String> entry : references.entrySet()
)
                 {
                     logger.error( entry.getValue() + " " + entry.getKey() );
                 }
@@ -609,8 +620,8 @@ public class MavenCli
         }
     }
 
-    private void logSummary( ExceptionSummary summary, Map<String, String> references,
String indent,
-                             boolean showErrors )
+    private void logSummary( final ExceptionSummary summary, final Map<String, String>
references, String indent,
+                             final boolean showErrors )
     {
         String referenceKey = "";
 
@@ -638,11 +649,11 @@ public class MavenCli
             }
         }
 
-        String[] lines = msg.split( "(\r\n)|(\r)|(\n)" );
+        final String[] lines = msg.split( "(\r\n)|(\r)|(\n)" );
 
         for ( int i = 0; i < lines.length; i++ )
         {
-            String line = indent + lines[i].trim();
+            final String line = indent + lines[i].trim();
 
             if ( i == lines.length - 1 && ( showErrors || ( summary.getException()
instanceof InternalErrorException ) ) )
             {
@@ -656,19 +667,19 @@ public class MavenCli
 
         indent += "  ";
 
-        for ( ExceptionSummary child : summary.getChildren() )
+        for ( final ExceptionSummary child : summary.getChildren() )
         {
             logSummary( child, references, indent, showErrors );
         }
     }
 
-    protected ModelProcessor createModelProcessor( PlexusContainer container )
+    protected ModelProcessor createModelProcessor( final PlexusContainer container )
         throws ComponentLookupException
     {
         return container.lookup( ModelProcessor.class );
     }
 
-    private void settings( CliRequest cliRequest )
+    private void settings( final CliRequest cliRequest )
         throws Exception
     {
         File userSettingsFile;
@@ -680,8 +691,7 @@ public class MavenCli
 
             if ( !userSettingsFile.isFile() )
             {
-                throw new FileNotFoundException( "The specified user settings file does not
exist: "
-                    + userSettingsFile );
+                throw new FileNotFoundException( "The specified user settings file does not
exist: " + userSettingsFile );
             }
         }
         else
@@ -700,7 +710,7 @@ public class MavenCli
             if ( !globalSettingsFile.isFile() )
             {
                 throw new FileNotFoundException( "The specified global settings file does
not exist: "
-                    + globalSettingsFile );
+                                + globalSettingsFile );
             }
         }
         else
@@ -711,7 +721,7 @@ public class MavenCli
         cliRequest.request.setGlobalSettingsFile( globalSettingsFile );
         cliRequest.request.setUserSettingsFile( userSettingsFile );
 
-        SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
+        final SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
         settingsRequest.setGlobalSettingsFile( globalSettingsFile );
         settingsRequest.setUserSettingsFile( userSettingsFile );
         settingsRequest.setSystemProperties( cliRequest.systemProperties );
@@ -720,11 +730,13 @@ public class MavenCli
         eventSpyDispatcher.onEvent( settingsRequest );
 
         logger.debug( "Reading global settings from "
-            + getSettingsLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile()
) );
+                        + getSettingsLocation( settingsRequest.getGlobalSettingsSource(),
+                                               settingsRequest.getGlobalSettingsFile() )
);
         logger.debug( "Reading user settings from "
-            + getSettingsLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile()
) );
+                        + getSettingsLocation( settingsRequest.getUserSettingsSource(),
+                                               settingsRequest.getUserSettingsFile() ) );
 
-        SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
+        final SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest
);
 
         eventSpyDispatcher.onEvent( settingsResult );
 
@@ -735,7 +747,7 @@ public class MavenCli
             logger.warn( "" );
             logger.warn( "Some problems were encountered while building the effective settings"
);
 
-            for ( SettingsProblem problem : settingsResult.getProblems() )
+            for ( final SettingsProblem problem : settingsResult.getProblems() )
             {
                 logger.warn( problem.getMessage() + " @ " + problem.getLocation() );
             }
@@ -744,7 +756,7 @@ public class MavenCli
         }
     }
 
-    private Object getSettingsLocation( SettingsSource source, File file )
+    private Object getSettingsLocation( final SettingsSource source, final File file )
     {
         if ( source != null )
         {
@@ -753,21 +765,22 @@ public class MavenCli
         return file;
     }
 
-    private MavenExecutionRequest populateRequest( CliRequest cliRequest )
+    private MavenExecutionRequest populateRequest( final CliRequest cliRequest )
+        throws MirrorRouterConfigurationException
     {
-        MavenExecutionRequest request = cliRequest.request;
-        CommandLine commandLine = cliRequest.commandLine;
-        String workingDirectory = cliRequest.workingDirectory;
-        boolean quiet = cliRequest.quiet;
-        boolean showErrors = cliRequest.showErrors;
+        final MavenExecutionRequest request = cliRequest.request;
+        final CommandLine commandLine = cliRequest.commandLine;
+        final String workingDirectory = cliRequest.workingDirectory;
+        final boolean quiet = cliRequest.quiet;
+        final boolean showErrors = cliRequest.showErrors;
 
-        String[] deprecatedOptions = { "up", "npu", "cpu", "npr" };
-        for ( String deprecatedOption : deprecatedOptions )
+        final String[] deprecatedOptions = { "up", "npu", "cpu", "npr" };
+        for ( final String deprecatedOption : deprecatedOptions )
         {
             if ( commandLine.hasOption( deprecatedOption ) )
             {
                 logger.warn( "Command line option -" + deprecatedOption
-                    + " is deprecated and will be removed in future Maven versions." );
+                                + " is deprecated and will be removed in future Maven versions."
);
             }
         }
 
@@ -791,8 +804,8 @@ public class MavenCli
         //
         // ----------------------------------------------------------------------
 
-        @SuppressWarnings("unchecked")
-        List<String> goals = commandLine.getArgList();
+        @SuppressWarnings( "unchecked" )
+        final List<String> goals = commandLine.getArgList();
 
         boolean recursive = true;
 
@@ -840,28 +853,28 @@ public class MavenCli
             globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN;
         }
 
-        File baseDirectory = new File( workingDirectory, "" ).getAbsoluteFile();
+        final File baseDirectory = new File( workingDirectory, "" ).getAbsoluteFile();
 
         // ----------------------------------------------------------------------
         // Profile Activation
         // ----------------------------------------------------------------------
 
-        List<String> activeProfiles = new ArrayList<String>();
+        final List<String> activeProfiles = new ArrayList<String>();
 
-        List<String> inactiveProfiles = new ArrayList<String>();
+        final List<String> inactiveProfiles = new ArrayList<String>();
 
         if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) )
         {
-            String[] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES
);
+            final String[] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES
);
             if ( profileOptionValues != null )
             {
                 for ( int i = 0; i < profileOptionValues.length; ++i )
                 {
-                    StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i],
"," );
+                    final StringTokenizer profileTokens = new StringTokenizer( profileOptionValues[i],
"," );
 
                     while ( profileTokens.hasMoreTokens() )
                     {
-                        String profileAction = profileTokens.nextToken().trim();
+                        final String profileAction = profileTokens.nextToken().trim();
 
                         if ( profileAction.startsWith( "-" ) || profileAction.startsWith(
"!" ) )
                         {
@@ -915,31 +928,43 @@ public class MavenCli
             userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE;
         }
 
-        request.setBaseDirectory( baseDirectory ).setGoals( goals )
-            .setSystemProperties( cliRequest.systemProperties )
-            .setUserProperties( cliRequest.userProperties )
-            .setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast
-            .setRecursive( recursive ) // default: true
-            .setShowErrors( showErrors ) // default: false
-            .addActiveProfiles( activeProfiles ) // optional
-            .addInactiveProfiles( inactiveProfiles ) // optional
-            .setExecutionListener( executionListener )
-            .setTransferListener( transferListener ) // default: batch mode which goes along
with interactive
-            .setUpdateSnapshots( updateSnapshots ) // default: false
-            .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false
-            .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
-            .setUserToolchainsFile( userToolchainsFile )
-            .setUserExtensionConfDir( MavenCli.DEFAULT_USER_EXT_CONF_DIR );
+        final MirrorRouterConfiguration routerConfig =
+            routerConfBuilder.build( new FileMirrorRouterConfigSource( DEFAULT_USER_EXT_CONF_DIR
) );
+
+        request.setBaseDirectory( baseDirectory )
+               .setGoals( goals )
+               .setSystemProperties( cliRequest.systemProperties )
+               .setUserProperties( cliRequest.userProperties )
+               .setReactorFailureBehavior( reactorFailureBehaviour )
+               // default: fail fast
+               .setRecursive( recursive )
+               // default: true
+               .setShowErrors( showErrors )
+               // default: false
+               .addActiveProfiles( activeProfiles )
+               // optional
+               .addInactiveProfiles( inactiveProfiles )
+               // optional
+               .setExecutionListener( executionListener )
+               .setTransferListener( transferListener )
+               // default: batch mode which goes along with interactive
+               .setUpdateSnapshots( updateSnapshots )
+               // default: false
+               .setNoSnapshotUpdates( noSnapshotUpdates )
+               // default: false
+               .setGlobalChecksumPolicy( globalChecksumPolicy )
+               // default: warn
+               .setUserToolchainsFile( userToolchainsFile );
 
         if ( alternatePomFile != null )
         {
-            File pom = resolveFile( new File( alternatePomFile ), workingDirectory );
+            final File pom = resolveFile( new File( alternatePomFile ), workingDirectory
);
 
             request.setPom( pom );
         }
         else
         {
-            File pom = modelProcessor.locatePom( baseDirectory );
+            final File pom = modelProcessor.locatePom( baseDirectory );
 
             if ( pom.isFile() )
             {
@@ -959,18 +984,17 @@ public class MavenCli
 
         if ( commandLine.hasOption( CLIManager.PROJECT_LIST ) )
         {
-            String[] values = commandLine.getOptionValues( CLIManager.PROJECT_LIST );
-            List<String> projects = new ArrayList<String>();
+            final String[] values = commandLine.getOptionValues( CLIManager.PROJECT_LIST
);
+            final List<String> projects = new ArrayList<String>();
             for ( int i = 0; i < values.length; i++ )
             {
-                String[] tmp = StringUtils.split( values[i], "," );
+                final String[] tmp = StringUtils.split( values[i], "," );
                 projects.addAll( Arrays.asList( tmp ) );
             }
             request.setSelectedProjects( projects );
         }
 
-        if ( commandLine.hasOption( CLIManager.ALSO_MAKE )
-                        && !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS
) )
+        if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) && !commandLine.hasOption(
CLIManager.ALSO_MAKE_DEPENDENTS ) )
         {
             request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM );
         }
@@ -997,10 +1021,13 @@ public class MavenCli
             request.setLocalRepositoryPath( localRepoProperty );
         }
 
-        final String threadConfiguration = commandLine.hasOption( CLIManager.THREADS )
-            ? commandLine.getOptionValue( CLIManager.THREADS )
-            : request.getSystemProperties().getProperty(
-                MavenCli.THREADS_DEPRECATED ); // TODO: Remove this setting. Note that the
int-tests use it
+        final String threadConfiguration =
+            commandLine.hasOption( CLIManager.THREADS ) ? commandLine.getOptionValue( CLIManager.THREADS
)
+                            : request.getSystemProperties().getProperty( MavenCli.THREADS_DEPRECATED
); // TODO: Remove
+                                                                                        
               // this setting.
+                                                                                        
               // Note that the
+                                                                                        
               // int-tests use
+                                                                                        
               // it
 
         if ( threadConfiguration != null )
         {
@@ -1018,7 +1045,7 @@ public class MavenCli
         return request;
     }
 
-    static File resolveFile( File file, String workingDirectory )
+    static File resolveFile( final File file, final String workingDirectory )
     {
         if ( file == null )
         {
@@ -1043,7 +1070,8 @@ public class MavenCli
     // System properties handling
     // ----------------------------------------------------------------------
 
-    static void populateProperties( CommandLine commandLine, Properties systemProperties,
Properties userProperties )
+    static void populateProperties( final CommandLine commandLine, final Properties systemProperties,
+                                    final Properties userProperties )
     {
         EnvironmentUtils.addEnvVars( systemProperties );
 
@@ -1055,7 +1083,7 @@ public class MavenCli
 
         if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) )
         {
-            String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY
);
+            final String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY
);
 
             if ( defStrs != null )
             {
@@ -1069,13 +1097,13 @@ public class MavenCli
         systemProperties.putAll( System.getProperties() );
     }
 
-    private static void setCliProperty( String property, Properties properties )
+    private static void setCliProperty( final String property, final Properties properties
)
     {
         String name;
 
         String value;
 
-        int i = property.indexOf( "=" );
+        final int i = property.indexOf( "=" );
 
         if ( i <= 0 )
         {
@@ -1103,22 +1131,32 @@ public class MavenCli
     static class CliRequest
     {
         String[] args;
+
         CommandLine commandLine;
+
         ClassWorld classWorld;
+
         String workingDirectory;
+
         boolean debug;
+
         boolean quiet;
+
         boolean showErrors = true;
+
         PrintStream fileStream;
+
         Properties userProperties = new Properties();
+
         Properties systemProperties = new Properties();
+
         MavenExecutionRequest request;
 
-        CliRequest( String[] args, ClassWorld classWorld )
+        CliRequest( final String[] args, final ClassWorld classWorld )
         {
             this.args = args;
             this.classWorld = classWorld;
-            this.request = new DefaultMavenExecutionRequest();
+            request = new DefaultMavenExecutionRequest();
         }
     }
 
@@ -1128,7 +1166,7 @@ public class MavenCli
 
         public int exitCode;
 
-        public ExitException( int exitCode )
+        public ExitException( final int exitCode )
         {
             this.exitCode = exitCode;
         }



Mime
View raw message