From 34c2aa8acc2f3a27207fb892e70bd7593cb1a9ad Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Tue, 19 Jan 2010 21:38:37 +0000 Subject: [PATCH] o Clean up properties processing in CLI git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@900969 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/maven/cli/MavenCli.java | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index 8e07dbc3ad..0f26efc990 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -147,13 +147,14 @@ public class MavenCli { initialize( cliRequest ); // Need to process cli options first to get possible logging options - cli( cliRequest ); - logging( cliRequest ); + cli( cliRequest ); + logging( cliRequest ); commands( cliRequest ); + properties( cliRequest ); container( cliRequest ); settings( cliRequest ); populateRequest( cliRequest ); - encryption( cliRequest ); + encryption( cliRequest ); return execute( cliRequest ); } catch( ExitException e ) @@ -321,7 +322,12 @@ public class MavenCli logger.info( "Enabling strict checksum verification on all artifact downloads." ); } } - + + private void properties( CliRequest cliRequest ) + { + populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties ); + } + private void container( CliRequest cliRequest ) throws Exception { @@ -584,13 +590,11 @@ public class MavenCli cliRequest.request.setGlobalSettingsFile( globalSettingsFile ); cliRequest.request.setUserSettingsFile( userSettingsFile ); - populateProperties( cliRequest.request, cliRequest.commandLine ); - SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); settingsRequest.setGlobalSettingsFile( globalSettingsFile ); settingsRequest.setUserSettingsFile( userSettingsFile ); - settingsRequest.setSystemProperties( cliRequest.request.getSystemProperties() ); - settingsRequest.setUserProperties( cliRequest.request.getUserProperties() ); + settingsRequest.setSystemProperties( cliRequest.systemProperties ); + settingsRequest.setUserProperties( cliRequest.userProperties ); SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest ); @@ -610,15 +614,6 @@ public class MavenCli } } - private void populateProperties( MavenExecutionRequest request, CommandLine commandLine ) - { - Properties systemProperties = new Properties(); - Properties userProperties = new Properties(); - populateProperties( commandLine, systemProperties, userProperties ); - request.setUserProperties( userProperties ); - request.setSystemProperties( systemProperties ); - } - private MavenExecutionRequest populateRequest( CliRequest cliRequest ) { MavenExecutionRequest request = cliRequest.request; @@ -785,10 +780,6 @@ public class MavenCli loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_INFO; } - Properties systemProperties = new Properties(); - Properties userProperties = new Properties(); - populateProperties( commandLine, systemProperties, userProperties ); - File userToolchainsFile; if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ) { @@ -800,7 +791,10 @@ public class MavenCli userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE; } - request.setBaseDirectory( baseDirectory ).setGoals( goals ).setSystemProperties( systemProperties ).setUserProperties( userProperties ).setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast + request.setBaseDirectory( baseDirectory ).setGoals( goals ) + .setSystemProperties( cliRequest.systemProperties ) + .setUserProperties( cliRequest.userProperties ) + .setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast .setRecursive( recursive ) // default: true .setShowErrors( showErrors ) // default: false .setUsePluginUpdateOverride( pluginUpdateOverride ).addActiveProfiles( activeProfiles ) // optional @@ -978,6 +972,8 @@ public class MavenCli boolean quiet; boolean showErrors; PrintStream fileStream; + Properties userProperties = new Properties(); + Properties systemProperties = new Properties(); MavenExecutionRequest request; CliRequest( String[] args, ClassWorld classWorld )