MASSEMBLY-775 treat a leading / as absolute path
If we want to have somehow portable builds we also need to treat /
as absolute on Windows. This will be treated as disk-relative.
That means if you build on c: then /somedir will be c:\somedir
on a Windows box.
diff --git a/src/it/projects/file-sets/massembly-665/src/main/assembly/src.xml b/src/it/projects/file-sets/massembly-665/src/main/assembly/src.xml
index a6cd520..27f712c 100644
--- a/src/it/projects/file-sets/massembly-665/src/main/assembly/src.xml
+++ b/src/it/projects/file-sets/massembly-665/src/main/assembly/src.xml
@@ -36,6 +36,7 @@
</includes>
</fileSet>
<fileSet>
+ <!-- This points to an absolute path on the current drive -->
<directory>/src/test/java/test</directory>
<outputDirectory>conf</outputDirectory>
<includes>
diff --git a/src/it/projects/file-sets/massembly-665/verify.bsh b/src/it/projects/file-sets/massembly-665/verify.bsh
new file mode 100644
index 0000000..b189bf6
--- /dev/null
+++ b/src/it/projects/file-sets/massembly-665/verify.bsh
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.jar.*;
+
+boolean result = true;
+
+try
+{
+ result = new File( basedir, "target/massembly-665-1.0-SNAPSHOT-src/bin/aFile.txt" ).exists() &&
+ !new File( basedir, "target/massembly-665-1.0-SNAPSHOT-src/conf/aFile.txt" ).exists();
+}
+catch( IOException e )
+{
+ e.printStackTrace();
+ result = false;
+}
+
+return result;
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java
index 933f3e5..a10e7d0 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/task/AddFileSetsTask.java
@@ -186,7 +186,12 @@
{
fileSetDir = new File( sourceDirectory );
- if ( !fileSetDir.isAbsolute() )
+ // If the file is not absolute then it's a subpath of the current project basedir
+ // For OS compatibility we also must treat any path starting with "/" as absolute
+ // as File#isAbsolute() returns false for /absolutePath under Windows :(
+ // Note that in Windows an absolute path with / will be on the 'current drive'.
+ // But I think we can live with this.
+ if ( !fileSetDir.isAbsolute() && !fileSetDir.getPath().startsWith( "/" ) )
{
fileSetDir = new File( basedir, sourceDirectory );
}