maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1083092 - in /maven/release/trunk/maven-release-manager/src: main/java/org/apache/maven/shared/release/phase/ main/java/org/apache/maven/shared/release/util/ test/java/org/apache/maven/shared/release/util/
Date Fri, 18 Mar 2011 22:22:17 GMT
Author: olamy
Date: Fri Mar 18 22:22:17 2011
New Revision: 1083092

URL: http://svn.apache.org/viewvc?rev=1083092&view=rev
Log:
[MRELEASE-622] Creating label fails for ClearCase with message 'Unable to determine VOB for
pathname ".".'
Submitted by Anders Hammar.

Modified:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/ReleaseUtilTest.java

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java?rev=1083092&r1=1083091&r2=1083092&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/AbstractRewritePomsPhase.java
Fri Mar 18 22:22:17 2011
@@ -309,8 +309,17 @@ public abstract class AbstractRewritePom
             }
         }
 
+        String commonBasedir;
+        try
+        {
+        	commonBasedir = ReleaseUtil.getCommonBasedir( reactorProjects );
+        }
+        catch ( IOException e )
+        {
+        	throw new ReleaseExecutionException("Exception occurred while calculating common
basedir: " + e.getMessage(), e);
+        }
         transformScm( project, rootElement, namespace, releaseDescriptor, projectId, scmRepository,
result,
-                      ReleaseUtil.getCommonBasedir( reactorProjects ) );
+                      commonBasedir );
     }
 
     /**

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java?rev=1083092&r1=1083091&r2=1083092&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
Fri Mar 18 22:22:17 2011
@@ -154,7 +154,16 @@ public class CheckoutProjectFromScm
         String scmRelativePathProjectDirectory = scmResult.getRelativePathProjectDirectory();
         if ( StringUtils.isEmpty( scmRelativePathProjectDirectory ) )
         {
-            String basedir = ReleaseUtil.getCommonBasedir( reactorProjects );
+            String basedir;
+            try
+            {
+                basedir = ReleaseUtil.getCommonBasedir( reactorProjects );
+            }
+            catch ( IOException e )
+            {
+            	throw new ReleaseExecutionException("Exception occurred while calculating common
basedir: " + e.getMessage(), e);
+            }
+
             String rootProjectBasedir = rootProject.getBasedir().getAbsolutePath();
             if ( rootProjectBasedir.length() > basedir.length() )
             {

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java?rev=1083092&r1=1083091&r2=1083092&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/util/ReleaseUtil.java
Fri Mar 18 22:22:17 2011
@@ -44,7 +44,7 @@ public class ReleaseUtil
 
     public static final String POMv4 = "pom.xml";
 
-    private static final char FS = File.separatorChar;
+    private static final String FS = File.separator;
 
     /**
      * The line separator to use.
@@ -53,6 +53,7 @@ public class ReleaseUtil
 
     private ReleaseUtil()
     {
+        // noop
     }
 
     public static MavenProject getRootProject( List<MavenProject> reactorProjects )
@@ -164,7 +165,15 @@ public class ReleaseUtil
                                                                            List<MavenProject>
reactorProjects )
         throws ReleaseExecutionException
     {
-        String basedir = getCommonBasedir( reactorProjects );
+        String basedir;
+        try
+        {
+            basedir = getCommonBasedir( reactorProjects );
+        }
+        catch ( IOException e )
+        {
+        	throw new ReleaseExecutionException("Exception occurred while calculating common
basedir: " + e.getMessage(), e);
+        }
 
         int parentLevels =
             getBaseWorkingDirectoryParentCount( basedir,
@@ -180,11 +189,13 @@ public class ReleaseUtil
     }
 
     public static String getCommonBasedir( List<MavenProject> reactorProjects )
+        throws IOException
     {
         return getCommonBasedir( reactorProjects, FS );
     }
 
-    public static String getCommonBasedir( List<MavenProject> reactorProjects, char
separator )
+    public static String getCommonBasedir( List<MavenProject> reactorProjects, String
separator )
+        throws IOException
     {
         String[] baseDirs = new String[reactorProjects.size()];
         int idx = 0;
@@ -192,39 +203,28 @@ public class ReleaseUtil
         {
             MavenProject p = i.next();
 
-            // we can only normalize paths with /
-            String dir = FileUtils.normalize( p.getBasedir().getPath().replace( '\\', '/'
) );
-            if ( separator == '\\' )
-            {
-                // windows has case insensitive filesystem
-                // normalize to lowercase for comparison
-
-                // Not a comprehensive solution to case-insensitive filenames, but only seem
to be getting bitten by
-                // C: vs c: as the rest of the path is being returned consistently. Overall
this class should rely more
-                // on the Java IO classes instead of string parsing to avoid these issues.
-                dir = dir.toLowerCase( Locale.ENGLISH );
-            }
+            String dir = p.getBasedir().getCanonicalPath();
 
-            // always end in / so that we know what is a path and what is a partial directory
name in the next call
-            if ( !dir.endsWith( "/" ) )
+            // always end with separator so that we know what is a path and what is a partial
directory name in the
+            // next call
+            if ( !dir.endsWith( separator ) )
             {
-                dir = dir + "/";
+                dir = dir + separator;
             }
             baseDirs[idx++] = dir;
         }
 
         String basedir = StringUtils.getCommonPrefix( baseDirs );
 
-        if ( !basedir.endsWith( "/" ) )
+        if ( !basedir.endsWith( separator ) )
         {
-            basedir = basedir.substring( 0, basedir.lastIndexOf( "/" ) );
+            basedir = basedir.substring( 0, basedir.lastIndexOf( separator ) );
         }
 
-        if ( basedir.endsWith( "/" ) && basedir.length() > 1 )
+        if ( basedir.endsWith( separator ) && basedir.length() > 1 )
         {
             basedir = basedir.substring( 0, basedir.length() - 1 );
         }
-        basedir = basedir.replace( '/', separator );
 
         return basedir;
     }

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/ReleaseUtilTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/ReleaseUtilTest.java?rev=1083092&r1=1083091&r2=1083092&view=diff
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/ReleaseUtilTest.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/util/ReleaseUtilTest.java
Fri Mar 18 22:22:17 2011
@@ -41,17 +41,17 @@ public class ReleaseUtilTest
         assertNull( ReleaseUtil.getStandardPom( null ) );
     }
 
-    public void testGetCommonBasedirSingleProject()
+    public void testGetCommonBasedirSingleProject() throws Exception
     {
         assertEquals( "/working/directory/flat-multi-module/project", ReleaseUtil.getCommonBasedir(
-            Collections.singletonList( createProject( "/working/directory/flat-multi-module/project"
) ), '/' ) );
+            Collections.singletonList( createProject( "/working/directory/flat-multi-module/project"
) ), "/" ) );
     }
 
-    public void testGetCommonBasedirSingleProjectWindows()
+    public void testGetCommonBasedirSingleProjectWindows() throws Exception
     {
-        assertEquals( "c:\\working\\directory\\flat-multi-module\\project", ReleaseUtil.getCommonBasedir(
-            Collections.singletonList( createProject( "c:\\working\\directory\\flat-multi-module\\project"
) ),
-            '\\' ) );
+        assertEquals( "C:\\working\\directory\\flat-multi-module\\project", ReleaseUtil.getCommonBasedir(
+            Collections.singletonList( createProject( "C:\\working\\directory\\flat-multi-module\\project"
) ),
+            "\\" ) );
     }
 
     public void testGetCommonBasedirOfFlatMultiModule()
@@ -60,24 +60,25 @@ public class ReleaseUtilTest
         assertEquals( "/working/directory/flat-multi-module", ReleaseUtil.getCommonBasedir(
Arrays.asList(
             new MavenProject[]{createProject( "/working/directory/flat-multi-module/root-project"
),
                 createProject( "/working/directory/flat-multi-module/core" ),
-                createProject( "/working/directory/flat-multi-module/webapp" )} ), '/' )
);
+                createProject( "/working/directory/flat-multi-module/webapp" )} ), "/" )
);
     }
 
     public void testGetCommonBasedirOfFlatMultiModuleWindows()
         throws Exception
     {
-        assertEquals( "c:\\working\\directory\\flat-multi-module", ReleaseUtil.getCommonBasedir(
Arrays.asList(
-            new MavenProject[]{createProject( "c:\\working\\directory\\flat-multi-module\\root-project"
),
-                createProject( "c:\\working\\directory\\flat-multi-module\\core" ),
-                createProject( "c:\\working\\directory\\flat-multi-module\\webapp" )} ),
'\\' ) );
+        assertEquals( "C:\\working\\directory\\flat-multi-module", ReleaseUtil.getCommonBasedir(
Arrays.asList(
+            new MavenProject[]{createProject( "C:\\working\\directory\\flat-multi-module\\root-project"
),
+                createProject( "C:\\working\\directory\\flat-multi-module\\core" ),
+                createProject( "C:\\working\\directory\\flat-multi-module\\webapp" )} ),
"\\" ) );
     }
 
     public void testGetCommonBasedirUppercaseLowerCaseWindows()
         throws Exception
     {
-        assertEquals( "c:\\working\\root", ReleaseUtil.getCommonBasedir( Arrays.asList(
-            new MavenProject[]{createProject( "c:\\working\\root" ), createProject( "C:\\WoRkInG\\root\\project1"
),
-                createProject( "c:\\working\\root\\project2" )} ), '\\' ) );
+        assertEquals( "C:\\WORKING\\root", ReleaseUtil.getCommonBasedir( Arrays.asList(
+            new MavenProject[]{createProject( "c:\\WORKING\\root", "C:\\WORKING\\root" ),
+                createProject( "c:\\working\\root\\project1", "C:\\WORKING\\root\\project1"
),
+                createProject( "C:\\WORKING\\root\\project2", "C:\\WORKING\\root\\project2"
)} ), "\\" ) );
     }
 
     public void testGetCommonBasedirOfFlatMultiModuleSimilarArtifactIds()
@@ -86,7 +87,7 @@ public class ReleaseUtilTest
         assertEquals( "/working/directory/flat-multi-module", ReleaseUtil.getCommonBasedir(
Arrays.asList(
             new MavenProject[]{createProject( "/working/directory/flat-multi-module/release-parent"
),
                 createProject( "/working/directory/flat-multi-module/release-module1" ),
-                createProject( "/working/directory/flat-multi-module/release-module2" )}
), '/' ) );
+                createProject( "/working/directory/flat-multi-module/release-module2" )}
), "/" ) );
     }
 
     public void testGetCommonBasedirOfFlatMultiModuleSimilarArtifactIdsWindows()
@@ -95,7 +96,7 @@ public class ReleaseUtilTest
         assertEquals( "c:\\working\\directory\\flat-multi-module", ReleaseUtil.getCommonBasedir(
Arrays.asList(
             new MavenProject[]{createProject( "c:\\working\\directory\\flat-multi-module\\release-parent"
),
                 createProject( "c:\\working\\directory\\flat-multi-module\\release-module1"
),
-                createProject( "c:\\working\\directory\\flat-multi-module\\release-module2"
)} ), '\\' ) );
+                createProject( "c:\\working\\directory\\flat-multi-module\\release-module2"
)} ), "\\" ) );
     }
 
     public void testGetCommonBasedirOfRegularMultiModule()
@@ -104,7 +105,7 @@ public class ReleaseUtilTest
         assertEquals( "/working/directory/flat-multi-module", ReleaseUtil.getCommonBasedir(
Arrays.asList(
             new MavenProject[]{createProject( "/working/directory/flat-multi-module" ),
                 createProject( "/working/directory/flat-multi-module/core" ),
-                createProject( "/working/directory/flat-multi-module/webapp" )} ), '/' )
);
+                createProject( "/working/directory/flat-multi-module/webapp" )} ), "/" )
);
     }
 
     public void testGetCommonBasedirOfRegularMultiModuleParentNotBeeingFirstInReactor()
@@ -114,7 +115,7 @@ public class ReleaseUtilTest
             new MavenProject[]{
                 createProject( "/working/directory/flat-multi-module/core" ),
                 createProject( "/working/directory/flat-multi-module" ),
-                createProject( "/working/directory/flat-multi-module/webapp" )} ), '/' )
);
+                createProject( "/working/directory/flat-multi-module/webapp" )} ), "/" )
);
     }
 
     public void testGetCommonBasedirOfRegularMultiModuleWindowsPath()
@@ -124,7 +125,7 @@ public class ReleaseUtilTest
             new MavenProject[]{
                 createProject( "c:\\working\\directory\\flat-multi-module\\core" ),
                 createProject( "c:\\working\\directory\\flat-multi-module" ),
-                createProject( "c:\\working\\directory\\flat-multi-module\\webapp" )} ),
'\\' ) );
+                createProject( "c:\\working\\directory\\flat-multi-module\\webapp" )} ),
"\\" ) );
     }
 
     public void testGetCommonBasedirOfFlatMultiModuleWithMultipleLevels()
@@ -135,7 +136,7 @@ public class ReleaseUtilTest
                 createProject( "/working/directory/flat-multi-module/core" ),
                 createProject( "/working/directory/flat-multi-module/common/utils" ),
                 createProject( "/working/directory/flat-multi-module/common/xml" ),
-                createProject( "/working/directory/flat-multi-module/webapp" )} ), '/' )
);
+                createProject( "/working/directory/flat-multi-module/webapp" )} ), "/" )
);
     }
 
     public void testGetCommonBasedirOfFlatMultiModuleWithDescendingHierarchy()
@@ -146,7 +147,7 @@ public class ReleaseUtilTest
                 createProject( "/working/directory/flat-multi-module/level/1/2" ),
                 createProject( "/working/directory/flat-multi-module/level/1" ),
                 createProject( "/working/directory/flat-multi-module/level" ),
-                createProject( "/working/directory/flat-multi-module/other" )} ), '/' ) );
+                createProject( "/working/directory/flat-multi-module/other" )} ), "/" ) );
     }
 
     public void testGetBaseScmUrlSingleLevel()
@@ -223,13 +224,24 @@ public class ReleaseUtilTest
         assertEquals( 3, ReleaseUtil.getBaseWorkingDirectoryParentCount( basedir, workingDirectory
) );
     }
 
-    private static MavenProject createProject( final String basedir )
+    private static MavenProject createProject( String basedir )
+    {
+    	return createProject( basedir, basedir );
+    }
+    
+    private static MavenProject createProject( final String basedirPath, final String basedirCanonicalPath
)
     {
         return new MavenProject()
         {
             public File getBasedir()
             {
-                return new File( basedir );
+                return new File( basedirPath )
+                {
+                	public String getCanonicalPath()
+                	{
+                		return basedirCanonicalPath;
+                	}
+                };
             }
         };
     }



Mime
View raw message