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/01 22:52:07 UTC

[maven-assembly-plugin] branch master updated (168366f -> 0b8ea5e)

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

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


    from 168366f  Fixed checkstyle issue.
     new 9c56b46  MASSEMBLY-919 IT for use case
     new d4fcbbb  Merge branch 'MASSEMBLY-919'
     new fda1471  MASSEMBLY-775 treat a leading / as absolute path
     new 9b5ee0b  MASSEMBLY-775 outputDirectory is completely irrelevant for absolute paths
     new 0b8ea5e  MASSEMBLY-775 make isAbsolute() check more general

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../massembly-919/bundle/assembly.xml}             |  17 ++-
 .../bundle}/pom.xml                                | 138 +++++++++++----------
 .../child1 => massembly-919/maindep}/pom.xml       |  23 ++--
 .../child1 => massembly-919}/pom.xml               |  20 +--
 .../child1 => massembly-919/testdep}/pom.xml       |  31 +++--
 .../testdep/src/main/java/test/SomeTestHelper.java |   8 +-
 .../{massembly-732 => massembly-919}/verify.bsh    |  11 +-
 .../massembly-665/src/main/assembly/src.xml        |   1 +
 .../massembly-665}/verify.bsh                      |   3 +-
 .../archive/phase/FileItemAssemblyPhase.java       |   5 +-
 .../archive/phase/ModuleSetAssemblyPhase.java      |   3 +-
 .../assembly/archive/task/AddFileSetsTask.java     |  11 +-
 .../plugins/assembly/utils/AssemblyFileUtils.java  |  12 ++
 .../archive/phase/FileItemAssemblyPhaseTest.java   |  13 --
 14 files changed, 171 insertions(+), 125 deletions(-)
 copy src/it/projects/{dependency-sets/depSet-enum-vs-wildcard/enum/src/main/assembly/bin.xml => bugs/massembly-919/bundle/assembly.xml} (70%)
 copy src/it/projects/bugs/{massembly-580 => massembly-919/bundle}/pom.xml (59%)
 copy src/it/projects/bugs/{massembly-583/child1 => massembly-919/maindep}/pom.xml (67%)
 copy src/it/projects/bugs/{massembly-583/child1 => massembly-919}/pom.xml (63%)
 copy src/it/projects/bugs/{massembly-583/child1 => massembly-919/testdep}/pom.xml (54%)
 copy Jenkinsfile => src/it/projects/bugs/massembly-919/testdep/src/main/java/test/SomeTestHelper.java (94%)
 copy src/it/projects/bugs/{massembly-732 => massembly-919}/verify.bsh (82%)
 copy src/it/projects/{dependency-sets/dependencySet-withExecutedProject => file-sets/massembly-665}/verify.bsh (83%)


[maven-assembly-plugin] 02/05: Merge branch 'MASSEMBLY-919'

Posted by st...@apache.org.
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

commit d4fcbbb8e35f61ecb4f34d59d75463c138386859
Merge: 168366f 9c56b46
Author: Mark Struberg <st...@apache.org>
AuthorDate: Wed Jan 1 16:44:19 2020 +0100

    Merge branch 'MASSEMBLY-919'

 .../bugs/massembly-919/bundle/assembly.xml         | 34 +++++++++++
 src/it/projects/bugs/massembly-919/bundle/pom.xml  | 71 ++++++++++++++++++++++
 src/it/projects/bugs/massembly-919/maindep/pom.xml | 35 +++++++++++
 src/it/projects/bugs/massembly-919/pom.xml         | 34 +++++++++++
 src/it/projects/bugs/massembly-919/testdep/pom.xml | 43 +++++++++++++
 .../testdep/src/main/java/test/SomeTestHelper.java | 24 ++++++++
 src/it/projects/bugs/massembly-919/verify.bsh      | 59 ++++++++++++++++++
 7 files changed, 300 insertions(+)


[maven-assembly-plugin] 01/05: MASSEMBLY-919 IT for use case

Posted by st...@apache.org.
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

commit 9c56b46fec0903592ccb5099c8580064a0291211
Author: Mark Struberg <st...@apache.org>
AuthorDate: Thu Dec 19 16:48:02 2019 +0100

    MASSEMBLY-919 IT for use case
    
    seems all is perfectly green right now...
---
 .../bugs/massembly-919/bundle/assembly.xml         | 34 +++++++++++
 src/it/projects/bugs/massembly-919/bundle/pom.xml  | 71 ++++++++++++++++++++++
 src/it/projects/bugs/massembly-919/maindep/pom.xml | 35 +++++++++++
 src/it/projects/bugs/massembly-919/pom.xml         | 34 +++++++++++
 src/it/projects/bugs/massembly-919/testdep/pom.xml | 43 +++++++++++++
 .../testdep/src/main/java/test/SomeTestHelper.java | 24 ++++++++
 src/it/projects/bugs/massembly-919/verify.bsh      | 59 ++++++++++++++++++
 7 files changed, 300 insertions(+)

diff --git a/src/it/projects/bugs/massembly-919/bundle/assembly.xml b/src/it/projects/bugs/massembly-919/bundle/assembly.xml
new file mode 100644
index 0000000..62da11e
--- /dev/null
+++ b/src/it/projects/bugs/massembly-919/bundle/assembly.xml
@@ -0,0 +1,34 @@
+<!--
+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.
+-->
+<assembly>
+    <id>bin</id>
+    <formats>
+        <format>zip</format>
+    </formats>
+    <dependencySets>
+        <dependencySet>
+            <useProjectArtifact>true</useProjectArtifact>
+            <outputDirectory>tools</outputDirectory>
+            <unpack>false</unpack>
+            <!-- runtime scope assembles compile and runtime dependencies, but skips those with provided scope. -->
+            <scope>runtime</scope>
+            <useTransitiveFiltering>true</useTransitiveFiltering>
+        </dependencySet>
+    </dependencySets>
+</assembly>
diff --git a/src/it/projects/bugs/massembly-919/bundle/pom.xml b/src/it/projects/bugs/massembly-919/bundle/pom.xml
new file mode 100644
index 0000000..32e2302
--- /dev/null
+++ b/src/it/projects/bugs/massembly-919/bundle/pom.xml
@@ -0,0 +1,71 @@
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>mygroup</groupId>
+        <artifactId>project2</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>project-bundle</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>mygroup</groupId>
+            <artifactId>project-maindep</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>mygroup</groupId>
+            <artifactId>project-testdep</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>${testVersion}</version>
+                <configuration>
+                    <descriptors>
+                        <descriptor>assembly.xml</descriptor>
+                    </descriptors>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>single</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/src/it/projects/bugs/massembly-919/maindep/pom.xml b/src/it/projects/bugs/massembly-919/maindep/pom.xml
new file mode 100644
index 0000000..4796414
--- /dev/null
+++ b/src/it/projects/bugs/massembly-919/maindep/pom.xml
@@ -0,0 +1,35 @@
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>mygroup</groupId>
+        <artifactId>project2</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>project-maindep</artifactId>
+
+
+
+</project>
diff --git a/src/it/projects/bugs/massembly-919/pom.xml b/src/it/projects/bugs/massembly-919/pom.xml
new file mode 100644
index 0000000..3280f6f
--- /dev/null
+++ b/src/it/projects/bugs/massembly-919/pom.xml
@@ -0,0 +1,34 @@
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>mygroup</groupId>
+    <artifactId>project2</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>testdep</module>
+        <module>maindep</module>
+        <module>bundle</module>
+    </modules>
+</project>
diff --git a/src/it/projects/bugs/massembly-919/testdep/pom.xml b/src/it/projects/bugs/massembly-919/testdep/pom.xml
new file mode 100644
index 0000000..c4234a5
--- /dev/null
+++ b/src/it/projects/bugs/massembly-919/testdep/pom.xml
@@ -0,0 +1,43 @@
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>mygroup</groupId>
+        <artifactId>project2</artifactId>
+        <version>0.0.1-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>project-testdep</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-assembly-plugin</artifactId>
+            <version>@project.version@</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+
+
+</project>
diff --git a/src/it/projects/bugs/massembly-919/testdep/src/main/java/test/SomeTestHelper.java b/src/it/projects/bugs/massembly-919/testdep/src/main/java/test/SomeTestHelper.java
new file mode 100644
index 0000000..9f7e3e8
--- /dev/null
+++ b/src/it/projects/bugs/massembly-919/testdep/src/main/java/test/SomeTestHelper.java
@@ -0,0 +1,24 @@
+package test;
+
+/*
+ * 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.
+ */
+
+public class SomeTestHelper
+{
+}
diff --git a/src/it/projects/bugs/massembly-919/verify.bsh b/src/it/projects/bugs/massembly-919/verify.bsh
new file mode 100644
index 0000000..abd6036
--- /dev/null
+++ b/src/it/projects/bugs/massembly-919/verify.bsh
@@ -0,0 +1,59 @@
+/*
+ * 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.zip.*;
+
+
+
+boolean result = true;
+
+try
+{
+    File zipFile = new File( basedir, "bundle/target/project-bundle-0.0.1-SNAPSHOT-bin.zip" );
+    
+    if ( !zipFile.exists() || zipFile.isDirectory() )
+    {
+        System.err.println( "zip-file is missing or a directory." );
+        result = false;
+    }
+    
+    ZipFile zf = new ZipFile( zipFile );
+
+    zes = zf.entries();
+    while(zes.hasMoreElements())
+    {
+        ZipEntry ze = zes.nextElement();
+        if (ze.getName().contains("maven-assembly-plugin"))
+        {
+        System.err.println( "filename is incorrect" );
+        result = false;
+        }
+    }
+
+    zf.close();
+}
+catch( IOException e )
+{
+    e.printStackTrace();
+    result = false;
+}
+
+return result;


[maven-assembly-plugin] 04/05: MASSEMBLY-775 outputDirectory is completely irrelevant for absolute paths

Posted by st...@apache.org.
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

commit 9b5ee0bad651fbca2d6bc5a11345e56de8a62776
Author: Mark Struberg <st...@apache.org>
AuthorDate: Tue Dec 24 22:05:32 2019 +0100

    MASSEMBLY-775 outputDirectory is completely irrelevant for absolute paths
    
    The old code did log some warn based on an absolute path in the outputDirectory.
    But that's actually irrelevant as this is always the directory inside the zip/tar, etc.
    That means it is _always_ interpreted as relative!
    The only possible problem is the 'directory' attribute which
    denotes the source path!
---
 .../assembly/archive/phase/FileItemAssemblyPhase.java       |  2 --
 .../plugins/assembly/archive/task/AddFileSetsTask.java      |  3 ++-
 .../assembly/archive/phase/FileItemAssemblyPhaseTest.java   | 13 -------------
 3 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
index 6246b57..af10ee6 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
@@ -87,8 +87,6 @@ public class FileItemAssemblyPhase
 
             final String outputDirectory1 = fileItem.getOutputDirectory();
 
-            AssemblyFormatUtils.warnForPlatformSpecifics( getLogger(), outputDirectory1 );
-
             final String outputDirectory =
                 AssemblyFormatUtils.getOutputDirectory( outputDirectory1, configSource.getFinalName(), configSource,
                                                         AssemblyFormatUtils.moduleProjectInterpolator(
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 a10e7d0..e9a082e 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
@@ -110,9 +110,10 @@ public class AddFileSetsTask
         if ( destDirectory == null )
         {
             destDirectory = fileSet.getDirectory();
+
+            AssemblyFormatUtils.warnForPlatformSpecifics( logger, destDirectory );
         }
 
-        AssemblyFormatUtils.warnForPlatformSpecifics( logger, destDirectory );
 
         destDirectory =
             AssemblyFormatUtils.getOutputDirectory( destDirectory, configSource.getFinalName(), configSource,
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 07d2a71..bc24cb8 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
@@ -196,10 +196,6 @@ public class FileItemAssemblyPhaseTest
             macLogger.logger.error( "OS=Windows and the assembly descriptor contains a *nix-specific "
                                         + "root-relative reference (starting with slash): /" );
         }
-        else
-        {
-            macLogger.logger.warn( (String) anyObject() );
-        }
 
         final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
 
@@ -272,15 +268,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): /" );
-        }
-        else
-        {
-            macLogger.logger.warn( (String) anyObject() );
-        }
 
         final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver( mm );
 


[maven-assembly-plugin] 03/05: MASSEMBLY-775 treat a leading / as absolute path

Posted by st...@apache.org.
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

commit fda1471a728f8e97342d7c1102e91a27ac2bb176
Author: Mark Struberg <st...@apache.org>
AuthorDate: Tue Dec 24 20:42:52 2019 +0100

    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.
---
 .../massembly-665/src/main/assembly/src.xml        |  1 +
 src/it/projects/file-sets/massembly-665/verify.bsh | 37 ++++++++++++++++++++++
 .../assembly/archive/task/AddFileSetsTask.java     |  7 +++-
 3 files changed, 44 insertions(+), 1 deletion(-)

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 @@ under the License.
 		</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 @@ public class AddFileSetsTask
         {
             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 );
             }


[maven-assembly-plugin] 05/05: MASSEMBLY-775 make isAbsolute() check more general

Posted by st...@apache.org.
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

commit 0b8ea5e1d93ea387069b52a10234c1b4c217be80
Author: Mark Struberg <st...@apache.org>
AuthorDate: Wed Jan 1 23:50:55 2020 +0100

    MASSEMBLY-775 make isAbsolute() check more general
    
    We now also detect '/' as indicator for an absolute file
    in a more generic way.
---
 .../assembly/archive/phase/FileItemAssemblyPhase.java        |  3 ++-
 .../assembly/archive/phase/ModuleSetAssemblyPhase.java       |  3 ++-
 .../maven/plugins/assembly/archive/task/AddFileSetsTask.java |  3 ++-
 .../maven/plugins/assembly/utils/AssemblyFileUtils.java      | 12 ++++++++++++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
index af10ee6..4572449 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/FileItemAssemblyPhase.java
@@ -25,6 +25,7 @@ import org.apache.maven.plugins.assembly.format.AssemblyFormattingException;
 import org.apache.maven.plugins.assembly.format.ReaderFormatter;
 import org.apache.maven.plugins.assembly.model.Assembly;
 import org.apache.maven.plugins.assembly.model.FileItem;
+import org.apache.maven.plugins.assembly.utils.AssemblyFileUtils;
 import org.apache.maven.plugins.assembly.utils.AssemblyFormatUtils;
 import org.apache.maven.plugins.assembly.utils.TypeConversionUtils;
 import org.codehaus.plexus.archiver.Archiver;
@@ -73,7 +74,7 @@ public class FileItemAssemblyPhase
             // create a temp file with a different name.
             final String sourceName = source.getName();
 
-            if ( !source.isAbsolute() )
+            if ( !AssemblyFileUtils.isAbsolutePath( source ) )
             {
                 source = new File( basedir, sourcePath );
             }
diff --git a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java
index 81cf4c7..e35c8e8 100644
--- a/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java
+++ b/src/main/java/org/apache/maven/plugins/assembly/archive/phase/ModuleSetAssemblyPhase.java
@@ -38,6 +38,7 @@ import org.apache.maven.plugins.assembly.model.FileSet;
 import org.apache.maven.plugins.assembly.model.ModuleBinaries;
 import org.apache.maven.plugins.assembly.model.ModuleSet;
 import org.apache.maven.plugins.assembly.model.ModuleSources;
+import org.apache.maven.plugins.assembly.utils.AssemblyFileUtils;
 import org.apache.maven.plugins.assembly.utils.AssemblyFormatUtils;
 import org.apache.maven.plugins.assembly.utils.FilterUtils;
 import org.apache.maven.plugins.assembly.utils.ProjectUtils;
@@ -501,7 +502,7 @@ public class ModuleSetAssemblyPhase
         {
             final File sourceDir = new File( sourcePath );
 
-            if ( !sourceDir.isAbsolute() )
+            if ( !AssemblyFileUtils.isAbsolutePath( sourceDir ) )
             {
                 sourcePath = new File( moduleBasedir, sourcePath ).getAbsolutePath();
             }
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 e9a082e..5e44521 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
@@ -24,6 +24,7 @@ import org.apache.maven.plugins.assembly.archive.ArchiveCreationException;
 import org.apache.maven.plugins.assembly.format.AssemblyFormattingException;
 import org.apache.maven.plugins.assembly.format.ReaderFormatter;
 import org.apache.maven.plugins.assembly.model.FileSet;
+import org.apache.maven.plugins.assembly.utils.AssemblyFileUtils;
 import org.apache.maven.plugins.assembly.utils.AssemblyFormatUtils;
 import org.apache.maven.plugins.assembly.utils.TypeConversionUtils;
 import org.apache.maven.project.MavenProject;
@@ -192,7 +193,7 @@ public class AddFileSetsTask
             // 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( "/" ) )
+            if ( ! AssemblyFileUtils.isAbsolutePath( fileSetDir ) )
             {
                 fileSetDir = new File( basedir, sourceDirectory );
             }
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 0874d39..cbe2713 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
@@ -108,4 +108,16 @@ public final class AssemblyFileUtils
     {
         return isPropertyFile( file.getName() );
     }
+
+    /**
+     * This method exists because {@link File#isAbsolute()} is not OS independent.
+     *
+     * In addition to the check in {@link File#isAbsolute()} we will also test for a leading '/'.
+     *
+     * @return {@code true} if {@code File#isAbsolute()} or starts with a '/'
+     */
+    public static boolean isAbsolutePath( File dir )
+    {
+        return dir != null && ( dir.isAbsolute() || dir.getPath().startsWith( "/" ) );
+    }
 }