You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2020/01/04 23:24:51 UTC

[maven-assembly-plugin] branch master updated: MASSEMBLY-775 on Win* File#getPath() translates / to \

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-assembly-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 178d0d0  MASSEMBLY-775 on Win* File#getPath() translates / to \
178d0d0 is described below

commit 178d0d0e3af1557f0c1400de33cce9885e1d89ab
Author: Mark Struberg <st...@apache.org>
AuthorDate: Sun Jan 5 00:22:34 2020 +0100

    MASSEMBLY-775 on Win* File#getPath() translates / to \
    
    Thus we have to check \\ for detecting an absolute
    (on windows: drive-absolute) path. On *nix File#isAbsolute() works anyway.
    Moving to nio Path did not add any benefit, so I left it with File().
---
 .../org/apache/maven/plugins/assembly/utils/AssemblyFileUtils.java   | 4 +++-
 .../plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java    | 5 -----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFileUtils.java b/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFileUtils.java
index cbe2713..bfbd89d 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFileUtils.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/utils/AssemblyFileUtils.java
@@ -118,6 +118,8 @@ public final class AssemblyFileUtils
      */
     public static boolean isAbsolutePath( File dir )
     {
-        return dir != null && ( dir.isAbsolute() || dir.getPath().startsWith( "/" ) );
+        return dir != null
+                && ( dir.isAbsolute()
+                   || dir.getPath().startsWith( "\\" ) ); // on Win* platforms
     }
 }
diff --git a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java
index bc24cb8..3603066 100644
--- a/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java
+++ b/src/test/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhaseTest.java
@@ -191,11 +191,6 @@ public class FileItemAssemblyPhaseTest
         macCS.expectInterpolators();
 
         final MockAndControlForLogger macLogger = new MockAndControlForLogger( mm );
-        if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
-        {
-            macLogger.logger.error( "OS=Windows and the assembly descriptor contains a *nix-specific "
-                                        + "root-relative reference (starting with slash): /" );
-        }
 
         final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );