MNG-2835 Make sure the global settings are obeyed when they are the only settings provided

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@512890 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2007-02-28 18:21:05 +00:00
parent 37692fbea1
commit 24b3c86c9b
1 changed files with 23 additions and 25 deletions

View File

@ -119,6 +119,9 @@ public class MavenEmbedder
public static final File DEFAULT_USER_SETTINGS_FILE = new File( userMavenConfigurationHome, "settings.xml" ); public static final File DEFAULT_USER_SETTINGS_FILE = new File( userMavenConfigurationHome, "settings.xml" );
public static final File DEFAULT_GLOBAL_SETTINGS_FILE = new File( System
.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/settings.xml" );
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// //
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -613,13 +616,10 @@ public class MavenEmbedder
try try
{ {
if ( configuration.getUserSettingsFile() == null )
{
configuration.setUserSettingsFile( DEFAULT_USER_SETTINGS_FILE );
}
settings = settingsBuilder.buildSettings( configuration.getUserSettingsFile(), settings = settingsBuilder.buildSettings( configuration.getUserSettingsFile(),
configuration.getGlobalSettingsFile() ); configuration.getGlobalSettingsFile() );
System.out.println( "settings.getLocalRepository() = " + settings.getLocalRepository() );
} }
catch ( Exception e ) catch ( Exception e )
{ {
@ -721,32 +721,30 @@ public class MavenEmbedder
{ {
ConfigurationValidationResult result = new DefaultConfigurationValidationResult(); ConfigurationValidationResult result = new DefaultConfigurationValidationResult();
if ( configuration.getUserSettingsFile() == null )
{
configuration.setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );
}
Reader fileReader; Reader fileReader;
// User settings // User settings
try if ( configuration.getUserSettingsFile() != null )
{ {
fileReader = new FileReader( configuration.getUserSettingsFile() ); try
{
fileReader = new FileReader( configuration.getUserSettingsFile() );
new SettingsXpp3Reader().read( fileReader ); new SettingsXpp3Reader().read( fileReader );
} }
catch ( FileNotFoundException e ) catch ( FileNotFoundException e )
{ {
result.setUserSettingsFilePresent( false ); result.setUserSettingsFilePresent( false );
} }
catch ( IOException e ) catch ( IOException e )
{ {
result.setUserSettingsFileParses( false ); result.setUserSettingsFileParses( false );
} }
catch ( XmlPullParserException e ) catch ( XmlPullParserException e )
{ {
result.setUserSettingsFileParses( false ); result.setUserSettingsFileParses( false );
}
} }
// Global settings // Global settings