maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r739735 - in /maven/components/trunk: ./ maven-compat/src/main/java/org/apache/maven/project/path/ maven-core/src/main/java/org/apache/maven/settings/ maven-embedder/src/main/java/org/apache/maven/cli/
Date Sun, 01 Feb 2009 10:44:19 GMT
Author: bentmann
Date: Sun Feb  1 10:44:19 2009
New Revision: 739735

URL: http://svn.apache.org/viewvc?rev=739735&view=rev
Log:
[MNG-3951] Hide drive-relative paths from plugins

o Merged from r739385

Modified:
    maven/components/trunk/   (props changed)
    maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java

Propchange: maven/components/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb  1 10:44:19 2009
@@ -1,3 +1,4 @@
 /maven/components/branches/maven-2.0.10-RC:680477
 /maven/components/branches/maven-2.0.x:679206,708871,720042,726541,727548,727998,728264,728940,729060,729738,729785,730631
+/maven/components/branches/maven-2.1.x:739385
 /maven/components/trunk:688587-696625,696644-699681

Modified: maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java?rev=739735&r1=739734&r2=739735&view=diff
==============================================================================
--- maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
(original)
+++ maven/components/trunk/maven-compat/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
Sun Feb  1 10:44:19 2009
@@ -35,8 +35,6 @@
 {
     private static final String[] BASEDIR_EXPRESSIONS = {"${basedir}", "${pom.basedir}",
"${project.basedir}"};
 
-    private String FILE_SEPARATOR = "/";
-
     public void alignToBaseDirectory( Model model, File basedir )
     {
         Build build = model.getBuild();
@@ -83,10 +81,27 @@
 
     public String alignToBaseDirectory( String path, File basedir )
     {
+        if ( path == null )
+        {
+            return null;
+        }
+
         String s = stripBasedirToken( path );
 
-        if ( requiresBaseDirectoryAlignment( s ) )
+        File file = new File( s );
+        if ( file.isAbsolute() )
+        {
+            // path was already absolute, just normalize file separator and we're done
+            s = file.getPath();
+        }
+        else if ( file.getPath().startsWith( File.separator ) )
+        {
+            // drive-relative Windows path, don't align with project directory but with drive
root
+            s = file.getAbsolutePath();
+        }
+        else
         {
+            // an ordinary relative path, align with project directory
             s = new File( new File( basedir, s ).toURI().normalize() ).getAbsolutePath();
         }
 
@@ -147,25 +162,6 @@
         return path;
     }
 
-    private boolean requiresBaseDirectoryAlignment( String s )
-    {
-        if ( s != null )
-        {
-            File f = new File( s );
-
-            if ( s.startsWith( FILE_SEPARATOR ) || f.isAbsolute() )
-            {
-                return false;
-            }
-            else
-            {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
     public void unalignFromBaseDirectory( Model model, File basedir )
     {
         Build build = model.getBuild();

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java?rev=739735&r1=739734&r2=739735&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java
Sun Feb  1 10:44:19 2009
@@ -102,6 +102,17 @@
 
         userSettings = interpolate( userSettings, request );
 
+        // for the special case of a drive-relative Windows path, make sure it's absolute
to save plugins from trouble
+        String localRepository = userSettings.getLocalRepository();
+        if ( localRepository != null && localRepository.length() > 0 )
+        {
+            File file = new File( localRepository );
+            if ( !file.isAbsolute() && file.getPath().startsWith( File.separator
) )
+            {
+                userSettings.setLocalRepository( file.getAbsolutePath() );
+            }
+        }
+
         return userSettings;
     }
 

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java?rev=739735&r1=739734&r2=739735&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java
Sun Feb  1 10:44:19 2009
@@ -116,7 +116,15 @@
         {
             CLIReportingUtils.showVersion();
         }
-        
+
+        // Make sure the Maven home directory is an absolute path to save us from confusion
with say drive-relative
+        // Windows paths.
+        String mavenHome = System.getProperty( "maven.home" );
+        if ( mavenHome != null )
+        {
+            System.setProperty( "maven.home", new File( mavenHome ).getAbsolutePath() );
+        }
+
         MavenExecutionRequest request = CLIRequestUtils.buildRequest( commandLine, debug,
quiet, showErrors );
 
         Configuration configuration = buildEmbedderConfiguration( request, commandLine, classWorld
);



Mime
View raw message