You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2014/12/12 17:56:17 UTC

svn commit: r1644977 - in /maven/plugins/trunk/maven-assembly-plugin/src: it/projects/file-sets/platformspecific-filesets/ it/projects/file-sets/platformspecific-filesets/adir/ main/java/org/apache/maven/plugin/assembly/archive/task/ main/java/org/apac...

Author: krosenvold
Date: Fri Dec 12 16:56:16 2014
New Revision: 1644977

URL: http://svn.apache.org/r1644977
Log:
[MASSEMBLY-665] Added warnings about platform-depdendent filesets

Added:
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/adir/
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/adir/emptyfile.txt
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/invoker.properties
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/pom.xml
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/src.xml
    maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/verify.groovy
Modified:
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java
    maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhaseTest.java
    maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTaskTest.java

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/adir/emptyfile.txt
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/adir/emptyfile.txt?rev=1644977&view=auto
==============================================================================
    (empty)

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/invoker.properties?rev=1644977&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/invoker.properties (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/invoker.properties Fri Dec 12 16:56:16 2014
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals=clean org.apache.maven.plugins:maven-assembly-plugin:${testVersion}:single

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/pom.xml?rev=1644977&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/pom.xml (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/pom.xml Fri Dec 12 16:56:16 2014
@@ -0,0 +1,47 @@
+<?xml version='1.0'?>
+<!--
+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/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.maven.plugin.assembly.test</groupId>
+    <artifactId>it-project-parent</artifactId>
+    <version>1</version>
+  </parent>
+  
+  <groupId>test</groupId>
+  <artifactId>platform-specific-filesets</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <configuration>
+          <descriptors>
+            <descriptor>src.xml</descriptor>
+          </descriptors>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/src.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/src.xml?rev=1644977&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/src.xml (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/src.xml Fri Dec 12 16:56:16 2014
@@ -0,0 +1,40 @@
+<?xml version='1.0'?>
+<!--
+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 xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+  <id>src</id>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+    <fileSet>
+      <directory>adir</directory>
+    </fileSet>
+    <fileSet>
+      <directory>/adir</directory>
+    </fileSet>
+    <fileSet>
+      <directory>c:\adir</directory>
+    </fileSet>
+  </fileSets>
+</assembly>

Added: maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/verify.groovy
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/verify.groovy?rev=1644977&view=auto
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/verify.groovy (added)
+++ maven/plugins/trunk/maven-assembly-plugin/src/it/projects/file-sets/platformspecific-filesets/verify.groovy Fri Dec 12 16:56:16 2014
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+
+File assemblyDir = new File( basedir, "build.log" );
+String buildOutput  = org.codehaus.plexus.util.FileUtils.fileRead(assemblyDir)
+return buildOutput.contains("assembly descriptor contains a");

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java?rev=1644977&r1=1644976&r2=1644977&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTask.java Fri Dec 12 16:56:16 2014
@@ -27,6 +27,7 @@ import org.apache.maven.plugin.assembly.
 import org.apache.maven.plugin.assembly.utils.AssemblyFormatUtils;
 import org.apache.maven.plugin.assembly.utils.TypeConversionUtils;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.utils.Os;
 import org.codehaus.plexus.archiver.Archiver;
 import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
 import org.codehaus.plexus.logging.Logger;
@@ -112,21 +113,13 @@ public class AddFileSetsTask
             destDirectory = fileSet.getDirectory();
         }
 
+        warnForPlatformSpecifics( destDirectory );
+
         destDirectory =
             AssemblyFormatUtils.getOutputDirectory( destDirectory, configSource.getFinalName(), configSource,
                                                     AssemblyFormatUtils.moduleProjectInterpolator( moduleProject ),
                                                     AssemblyFormatUtils.artifactProjectInterpolator( project ) );
 
-
-/*
-        destDirectory =
-            AssemblyFormatUtils.getOutputDirectory( destDirectory, moduleProjectInterpolator(
-                moduleProject ), artifactProjectInterpolator( project ),
-                                                    finalNameInterpolator( configSource.getFinalName() ),
-                                                    createProjectInterpolator( configSource.getProject() ),
-                                                    configSource.getSessionExecutionUserInterpolator() );
-
- */
         if ( logger.isDebugEnabled() )
         {
             logger.debug( "FileSet[" + destDirectory + "]" + " dir perms: " + Integer.toString(
@@ -183,6 +176,48 @@ public class AddFileSetsTask
         }
     }
 
+    private void warnForPlatformSpecifics( String destDirectory )
+    {
+        if ( Os.isFamily( Os.FAMILY_WINDOWS ) )
+        {
+            if ( isLinuxRootReference( destDirectory ) )
+            {
+                logger.error( "OS=Windows and the assembly descriptor contains a *nix-specific root-relative-reference"
+                                  + " (starting with slash) " + destDirectory );
+            }
+            else if ( isWindowsPath( destDirectory ) )
+            {
+                logger.warn( "The assembly descriptor contains a *nix-specific root-relative-reference"
+                                 + " (starting with slash). This is non-portable and will fail on windows "
+                                 + destDirectory );
+            }
+        }
+        else
+        {
+            if ( isWindowsPath( destDirectory ) )
+            {
+                logger.error(
+                    "OS=Non-Windows and the assembly descriptor contains a windows-specific directory reference"
+                        + " (with a drive letter) " + destDirectory );
+            }
+            else if ( isLinuxRootReference( destDirectory ) )
+            {
+                logger.warn( "The assembly descriptor contains a filesystem-root relative reference,"
+                                 + "which is not cross platform compatible " + destDirectory );
+            }
+        }
+    }
+
+    static boolean isWindowsPath( String destDirectory )
+    {
+        return ( destDirectory.length() >= 2 && destDirectory.charAt( 1 ) == ':' );
+    }
+
+    static boolean isLinuxRootReference( String destDirectory )
+    {
+        return ( destDirectory.startsWith( "/" ) );
+    }
+
     File getFileSetDirectory( final FileSet fileSet, final File basedir, final File archiveBaseDir )
         throws ArchiveCreationException, AssemblyFormattingException
     {

Modified: maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java?rev=1644977&r1=1644976&r2=1644977&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/main/java/org/apache/maven/plugin/assembly/interpolation/AssemblyInterpolator.java Fri Dec 12 16:56:16 2014
@@ -81,7 +81,7 @@ public class AssemblyInterpolator
                 if ( !source.equals( interpolated ) && logger.isDebugEnabled() )
                 {
                     logger.debug(
-                        "Field" + contextDescription + " value: " + source + " interpolated to: " + interpolated );
+                        "Field " + contextDescription + " source: " + source + " interpolated to: " + interpolated );
                 }
                 return interpolated;
             }
@@ -108,7 +108,7 @@ public class AssemblyInterpolator
                 if ( !source.equals( interpolated ) )
                 {
                     logger.debug(
-                        "Field" + contextDescription + " value: " + source + " interpolated to: " + interpolated );
+                        "Field " + contextDescription + " source: " + source + " interpolated to: " + interpolated );
                 }
                 return interpolated;
             }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhaseTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhaseTest.java?rev=1644977&r1=1644976&r2=1644977&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhaseTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/phase/FileSetAssemblyPhaseTest.java Fri Dec 12 16:56:16 2014
@@ -99,7 +99,7 @@ public class FileSetAssemblyPhaseTest
 
         final MavenProject project = new MavenProject( new Model() );
 
-        macLogger.expectDebug( true, true );
+        macLogger.expectWarn( true, true );
 
         final int dirMode = Integer.parseInt( "777", 8 );
         final int fileMode = Integer.parseInt( "777", 8 );
@@ -145,6 +145,19 @@ public class FileSetAssemblyPhaseTest
             logger.debug( (String) anyObject() );
             EasyMock.expectLastCall().anyTimes();
         }
+        public void expectWarn( final boolean debugCheck, final boolean debugEnabled )
+        {
+            if ( debugCheck )
+            {
+                expect( logger.isDebugEnabled()).andReturn( debugEnabled ).anyTimes();
+            }
+
+            logger.debug( (String) anyObject() );
+            EasyMock.expectLastCall().anyTimes();
+            logger.warn( (String) anyObject() );
+            EasyMock.expectLastCall().anyTimes();
+        }
+
     }
 
 }

Modified: maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTaskTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTaskTest.java?rev=1644977&r1=1644976&r2=1644977&view=diff
==============================================================================
--- maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTaskTest.java (original)
+++ maven/plugins/trunk/maven-assembly-plugin/src/test/java/org/apache/maven/plugin/assembly/archive/task/AddFileSetsTaskTest.java Fri Dec 12 16:56:16 2014
@@ -231,6 +231,13 @@ public class AddFileSetsTaskTest
         mockManager.verifyAll();
     }
 
+    public void testWindowsPath(){
+        assertTrue(AddFileSetsTask.isWindowsPath( "C:\foobar" ));
+    }
+    public void testLinuxRootReferencePath(){
+        assertTrue( AddFileSetsTask.isLinuxRootReference( "/etc/home" ) );
+    }
+
     public void testExecute_ShouldThrowExceptionIfArchiveBasedirProvidedIsNonExistent()
         throws AssemblyFormattingException
     {