maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rfscho...@apache.org
Subject [maven-release] branch Paths updated: Optimize Path usage
Date Fri, 23 Mar 2018 13:39:28 GMT
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch Paths
in repository https://gitbox.apache.org/repos/asf/maven-release.git


The following commit(s) were added to refs/heads/Paths by this push:
     new f6ad39e  Optimize Path usage
f6ad39e is described below

commit f6ad39ee86665d004997f7c73fba848e2ae859b9
Author: rfscholte <rfscholte@apache.org>
AuthorDate: Fri Mar 23 14:39:23 2018 +0100

    Optimize Path usage
---
 .../shared/release/phase/CheckoutProjectFromScm.java     | 16 ++++++----------
 .../shared/release/phase/RewritePomsForBranchPhase.java  |  7 +++----
 .../shared/release/phase/RewritePomsForReleasePhase.java |  5 ++---
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
index 18a87e7..7c8f274 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
@@ -22,6 +22,7 @@ package org.apache.maven.shared.release.phase;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.LinkOption;
+import java.nio.file.Path;
 import java.util.List;
 
 import org.apache.maven.project.MavenProject;
@@ -222,10 +223,10 @@ public class CheckoutProjectFromScm
         String scmRelativePathProjectDirectory = scmResult.getRelativePathProjectDirectory();
         if ( StringUtils.isEmpty( scmRelativePathProjectDirectory ) )
         {
-            String basedir;
+            Path basedir;
             try
             {
-                basedir = ReleaseUtil.getCommonBasedir( reactorProjects ).toString();
+                basedir = ReleaseUtil.getCommonBasedir( reactorProjects );
             }
             catch ( IOException e )
             {
@@ -233,22 +234,17 @@ public class CheckoutProjectFromScm
                     + e.getMessage(), e );
             }
 
-            String rootProjectBasedir;
+            Path rootProjectBasedir;
             try
             {
-                rootProjectBasedir =
-                    rootProject.getBasedir().toPath().toRealPath( LinkOption.NOFOLLOW_LINKS
).toString();
+                rootProjectBasedir = rootProject.getBasedir().toPath().toRealPath( LinkOption.NOFOLLOW_LINKS
);
             }
             catch ( IOException e )
             {
                 throw new ReleaseExecutionException( e.getMessage(), e );
             }
             
-            
-            if ( rootProjectBasedir.length() > basedir.length() )
-            {
-                scmRelativePathProjectDirectory = rootProjectBasedir.substring( basedir.length()
+ 1 );
-            }
+            scmRelativePathProjectDirectory = basedir.relativize( rootProjectBasedir ).toString();
         }
         releaseDescriptor.setScmRelativePathProjectDirectory( scmRelativePathProjectDirectory
);
 
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java
b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java
index 05b1196..5259603 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForBranchPhase.java
@@ -22,7 +22,6 @@ package org.apache.maven.shared.release.phase;
 import java.io.IOException;
 import java.nio.file.LinkOption;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Model;
@@ -130,10 +129,10 @@ public class RewritePomsForBranchPhase
                 branchBase = "scm:svn:" + branchBase;
             }
 
-            String workingDirectory = project.getBasedir().toPath().toRealPath( LinkOption.NOFOLLOW_LINKS
).toString();
+            Path workingDirectory = project.getBasedir().toPath().toRealPath( LinkOption.NOFOLLOW_LINKS
);
 
-            int count =
-                ReleaseUtil.getBaseWorkingDirectoryParentCount( commonBasedir, Paths.get(
workingDirectory ) );
+            int count = ReleaseUtil.getBaseWorkingDirectoryParentCount( commonBasedir, workingDirectory
);
+            
             if ( scm.getConnection() != null )
             {
                 String rootUrl = ReleaseUtil.realignScmUrl( count, scm.getConnection() );
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java
b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java
index c7f265b..2c90bd3 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/RewritePomsForReleasePhase.java
@@ -22,7 +22,6 @@ package org.apache.maven.shared.release.phase;
 import java.io.IOException;
 import java.nio.file.LinkOption;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Model;
@@ -128,10 +127,10 @@ public class RewritePomsForReleasePhase
                 tagBase = "scm:svn:" + tagBase;
             }
 
-            String workingDirectory = project.getBasedir().toPath().toRealPath( LinkOption.NOFOLLOW_LINKS
).toString();
+            Path workingDirectory = project.getBasedir().toPath().toRealPath( LinkOption.NOFOLLOW_LINKS
);
 
             int count =
-                ReleaseUtil.getBaseWorkingDirectoryParentCount( commonBasedir, Paths.get(
workingDirectory ) );
+                ReleaseUtil.getBaseWorkingDirectoryParentCount( commonBasedir, workingDirectory
);
             if ( scm.getConnection() != null )
             {
                 String rootUrl = ReleaseUtil.realignScmUrl( count, scm.getConnection() );

-- 
To stop receiving notification emails like this one, please contact
rfscholte@apache.org.

Mime
View raw message