maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r379395 - /maven/components/branches/maven-2.0.x/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
Date Tue, 21 Feb 2006 09:06:45 GMT
Author: evenisse
Date: Tue Feb 21 01:06:42 2006
New Revision: 379395

URL: http://svn.apache.org/viewcvs?rev=379395&view=rev
Log:
Initialize global settings if file doesn't exist.

Modified:
    maven/components/branches/maven-2.0.x/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java

Modified: maven/components/branches/maven-2.0.x/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-2.0.x/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java?rev=379395&r1=379394&r2=379395&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
(original)
+++ maven/components/branches/maven-2.0.x/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
Tue Feb 21 01:06:42 2006
@@ -65,11 +65,11 @@
 
     public void initialize()
     {
-        userSettingsFile = getFile( userSettingsPath, "user.home",
-                                    MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION );
+        userSettingsFile =
+            getFile( userSettingsPath, "user.home", MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION
);
 
-        globalSettingsFile = getFile( globalSettingsPath, "maven.home",
-                                      MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION
);
+        globalSettingsFile =
+            getFile( globalSettingsPath, "maven.home", MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION
);
 
         getLogger().debug(
             "Building Maven global-level settings from: '" + globalSettingsFile.getAbsolutePath()
+ "'" );
@@ -92,26 +92,27 @@
             {
                 reader = new FileReader( settingsFile );
                 StringWriter sWriter = new StringWriter();
-                
+
                 IOUtil.copy( reader, sWriter );
-                
+
                 String rawInput = sWriter.toString();
-                
+
                 try
                 {
                     RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
                     interpolator.addValueSource( new EnvarBasedValueSource() );
-                    
+
                     rawInput = interpolator.interpolate( rawInput, "settings" );
                 }
                 catch ( Exception e )
                 {
-                    getLogger().warn( "Failed to initialize environment variable resolver.
Skipping environment substitution in settings." );
+                    getLogger().warn(
+                        "Failed to initialize environment variable resolver. Skipping environment
substitution in settings." );
                     getLogger().debug( "Failed to initialize envar resolver. Skipping resolution.",
e );
                 }
 
                 StringReader sReader = new StringReader( rawInput );
-                
+
                 SettingsXpp3Reader modelReader = new SettingsXpp3Reader();
 
                 settings = modelReader.read( sReader );
@@ -145,6 +146,11 @@
             Settings globalSettings = readSettings( globalSettingsFile );
             Settings userSettings = readSettings( userSettingsFile );
 
+            if ( globalSettings == null )
+            {
+                globalSettings = new Settings();
+            }
+
             if ( userSettings == null )
             {
                 userSettings = new Settings();
@@ -152,7 +158,7 @@
             }
 
             SettingsUtils.merge( userSettings, globalSettings, TrackableBase.GLOBAL_LEVEL
);
-            
+
             activateDefaultProfiles( userSettings );
 
             setLocalRepository( userSettings );
@@ -166,8 +172,8 @@
     private void activateDefaultProfiles( Settings settings )
     {
         List activeProfiles = settings.getActiveProfiles();
-        
-        for( Iterator profiles = settings.getProfiles().iterator(); profiles.hasNext(); )
+
+        for ( Iterator profiles = settings.getProfiles().iterator(); profiles.hasNext();
)
         {
             Profile profile = (Profile) profiles.next();
             if ( profile.getActivation() != null && profile.getActivation().isActiveByDefault()
)



Mime
View raw message