Author: kenney
Date: Sun Jul  9 21:30:50 2006
New Revision: 420419

URL: http://svn.apache.org/viewvc?rev=420419&view=rev
Log:
Partially reverted previous commit - two methods
were removed that were still referenced.

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/viewvc/maven/components/branches/maven-2.0.x/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java?rev=420419&r1=420418&r2=420419&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
 Sun Jul  9 21:30:50 2006
@@ -184,4 +184,75 @@
         }
     }
 
+    private void setLocalRepository( Settings userSettings )
+    {
+        // try using the local repository specified on the command line...
+        String localRepository = System.getProperty( 
MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION );
+
+        // otherwise, use the one in settings.xml
+        if ( localRepository == null || localRepository.length() < 1 )
+        {
+            localRepository = userSettings.getLocalRepository();
+        }
+
+        // if all of the above are missing, default to ~/.m2/repository.
+        if ( localRepository == null || localRepository.length() < 1 )
+        {
+            File mavenUserConfigurationDirectory = new File( userHome, ".m2" );
+            if ( !mavenUserConfigurationDirectory.exists() )
+            {
+                if ( !mavenUserConfigurationDirectory.mkdirs() )
+                {
+                    //throw a configuration exception
+                }
+            }
+
+            localRepository = new File( mavenUserConfigurationDirectory, 
"repository" ).getAbsolutePath();
+        }
+
+        userSettings.setLocalRepository( localRepository );
+    }
+
+    private File getFile( String pathPattern, String basedirSysProp, String 
altLocationSysProp )
+    {
+        // 
-------------------------------------------------------------------------------------
+        // Alright, here's the justification for all the regexp wizardry 
below...
+        //
+        // Continuum and other server-like apps may need to locate the 
user-level and 
+        // global-level settings somewhere other than ${user.home} and 
${maven.home},
+        // respectively. Using a simple replacement of these patterns will 
allow them
+        // to specify the absolute path to these files in a customized 
components.xml
+        // file. Ideally, we'd do full pattern-evaluation against the 
sysprops, but this
+        // is a first step. There are several replacements below, in order to 
normalize
+        // the path character before we operate on the string as a regex 
input, and 
+        // in order to avoid surprises with the File construction...
+        // 
-------------------------------------------------------------------------------------
+
+        String path = System.getProperty( altLocationSysProp );
+
+        if ( StringUtils.isEmpty( path ) )
+        {
+            // TODO: This replacing shouldn't be necessary as user.home should 
be in the
+            // context of the container and thus the value would be 
interpolated by Plexus
+            String basedir = System.getProperty( basedirSysProp );
+            if ( basedir == null )
+            {
+                basedir = System.getProperty( "user.dir" );
+            }
+
+            basedir = basedir.replaceAll( "\\\\", "/" );
+            basedir = basedir.replaceAll( "\\$", "\\\\\\$" );
+
+            path = pathPattern.replaceAll( "\\$\\{" + basedirSysProp + "\\}", 
basedir );
+            path = path.replaceAll( "\\\\", "/" );
+            path = path.replaceAll( "//", "/" );
+
+            return new File( path ).getAbsoluteFile();
+        }
+        else
+        {
+            return new File( path ).getAbsoluteFile();
+        }
+    }
+
 }


Reply via email to