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
This commit is contained in:
Benjamin Bentmann 2010-01-19 21:38:37 +00:00
parent 9168e66222
commit 34c2aa8acc
1 changed files with 18 additions and 22 deletions

View File

@ -147,13 +147,14 @@ public class MavenCli
{ {
initialize( cliRequest ); initialize( cliRequest );
// Need to process cli options first to get possible logging options // Need to process cli options first to get possible logging options
cli( cliRequest ); cli( cliRequest );
logging( cliRequest ); logging( cliRequest );
commands( cliRequest ); commands( cliRequest );
properties( cliRequest );
container( cliRequest ); container( cliRequest );
settings( cliRequest ); settings( cliRequest );
populateRequest( cliRequest ); populateRequest( cliRequest );
encryption( cliRequest ); encryption( cliRequest );
return execute( cliRequest ); return execute( cliRequest );
} }
catch( ExitException e ) catch( ExitException e )
@ -321,7 +322,12 @@ public class MavenCli
logger.info( "Enabling strict checksum verification on all artifact downloads." ); 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 ) private void container( CliRequest cliRequest )
throws Exception throws Exception
{ {
@ -584,13 +590,11 @@ public class MavenCli
cliRequest.request.setGlobalSettingsFile( globalSettingsFile ); cliRequest.request.setGlobalSettingsFile( globalSettingsFile );
cliRequest.request.setUserSettingsFile( userSettingsFile ); cliRequest.request.setUserSettingsFile( userSettingsFile );
populateProperties( cliRequest.request, cliRequest.commandLine );
SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
settingsRequest.setGlobalSettingsFile( globalSettingsFile ); settingsRequest.setGlobalSettingsFile( globalSettingsFile );
settingsRequest.setUserSettingsFile( userSettingsFile ); settingsRequest.setUserSettingsFile( userSettingsFile );
settingsRequest.setSystemProperties( cliRequest.request.getSystemProperties() ); settingsRequest.setSystemProperties( cliRequest.systemProperties );
settingsRequest.setUserProperties( cliRequest.request.getUserProperties() ); settingsRequest.setUserProperties( cliRequest.userProperties );
SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest ); 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 ) private MavenExecutionRequest populateRequest( CliRequest cliRequest )
{ {
MavenExecutionRequest request = cliRequest.request; MavenExecutionRequest request = cliRequest.request;
@ -785,10 +780,6 @@ public class MavenCli
loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_INFO; loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_INFO;
} }
Properties systemProperties = new Properties();
Properties userProperties = new Properties();
populateProperties( commandLine, systemProperties, userProperties );
File userToolchainsFile; File userToolchainsFile;
if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ) if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_TOOLCHAINS ) )
{ {
@ -800,7 +791,10 @@ public class MavenCli
userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE; 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 .setRecursive( recursive ) // default: true
.setShowErrors( showErrors ) // default: false .setShowErrors( showErrors ) // default: false
.setUsePluginUpdateOverride( pluginUpdateOverride ).addActiveProfiles( activeProfiles ) // optional .setUsePluginUpdateOverride( pluginUpdateOverride ).addActiveProfiles( activeProfiles ) // optional
@ -978,6 +972,8 @@ public class MavenCli
boolean quiet; boolean quiet;
boolean showErrors; boolean showErrors;
PrintStream fileStream; PrintStream fileStream;
Properties userProperties = new Properties();
Properties systemProperties = new Properties();
MavenExecutionRequest request; MavenExecutionRequest request;
CliRequest( String[] args, ClassWorld classWorld ) CliRequest( String[] args, ClassWorld classWorld )