You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2019/03/16 13:42:09 UTC

[maven-patch-plugin] 04/08: MPATCH-20 applied review comments

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

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

commit a77587e979d2f09f32d5d2194f401d157b0bb457
Author: Matthias Balke <ma...@googlemail.com>
AuthorDate: Thu Aug 30 21:15:43 2018 +0200

    MPATCH-20 applied review comments
---
 src/it/cant-exclude-patches-from-patches/pom.xml   |  4 +-
 .../pom.xml                                        |  9 +++--
 .../src/main/patches/first.patch                   | 26 +++++++++++++
 .../src/main/patches/second.patch                  | 25 ++++++++++++
 .../verify.bsh                                     | 45 ++++++++++++++++++++++
 src/it/exclude-patches-from-patchDirectory/pom.xml |  4 +-
 .../org/apache/maven/plugin/patch/ApplyMojo.java   | 11 ++++--
 7 files changed, 115 insertions(+), 9 deletions(-)

diff --git a/src/it/cant-exclude-patches-from-patches/pom.xml b/src/it/cant-exclude-patches-from-patches/pom.xml
index e13970e..7dbcb37 100644
--- a/src/it/cant-exclude-patches-from-patches/pom.xml
+++ b/src/it/cant-exclude-patches-from-patches/pom.xml
@@ -39,7 +39,9 @@
         <configuration>
           <targetDirectory>${basedir}</targetDirectory>
           <!-- this exclude does not work, as it is only excluding files from patchDirectory -->
-          <excludePattern>se*.patch</excludePattern>
+          <excludes>
+            <exclude>se*.patch</exclude>
+          </excludes>
           <!-- both patches should be executed -->
           <patches>
             <patch>first.patch</patch>
diff --git a/src/it/exclude-patches-from-patchDirectory/pom.xml b/src/it/exclude-multiple-patterns-from-patchDirectory/pom.xml
similarity index 88%
copy from src/it/exclude-patches-from-patchDirectory/pom.xml
copy to src/it/exclude-multiple-patterns-from-patchDirectory/pom.xml
index 6e5b626..d2fdf16 100644
--- a/src/it/exclude-patches-from-patchDirectory/pom.xml
+++ b/src/it/exclude-multiple-patterns-from-patchDirectory/pom.xml
@@ -21,8 +21,8 @@
   <modelVersion>4.0.0</modelVersion>
   
   <groupId>test</groupId>
-  <artifactId>exclude-patches-from-patchDirectory</artifactId>
-  <name>exclude-patches-from-patchDirectory</name>
+  <artifactId>exclude-multiple-patterns-from-patchDirectory</artifactId>
+  <name>exclude-multiple-patterns-from-patchDirectory</name>
   <version>1.0-SNAPSHOT</version>
 
   <properties>
@@ -38,7 +38,10 @@
 
         <configuration>
           <targetDirectory>${basedir}</targetDirectory>
-          <excludePattern>se*.patch</excludePattern>
+          <excludes>
+            <exclude>fi*st.patch</exclude>
+            <exclude>se*.patch</exclude>
+          </excludes>
           <!-- enables reading of patches from src/main/patches -->
           <naturalOrderProcessing>true</naturalOrderProcessing>
         </configuration>
diff --git a/src/it/exclude-multiple-patterns-from-patchDirectory/src/main/patches/first.patch b/src/it/exclude-multiple-patterns-from-patchDirectory/src/main/patches/first.patch
new file mode 100644
index 0000000..5c6f211
--- /dev/null
+++ b/src/it/exclude-multiple-patterns-from-patchDirectory/src/main/patches/first.patch
@@ -0,0 +1,26 @@
+#
+#  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.
+#
+Index: target/test.txt
+===================================================================
+--- target/test.txt	(revision 0)
++++ target/test.txt	(revision 0)
+@@ -0,0 +1 @@
++This is a test.
+\ No newline at end of file
+
diff --git a/src/it/exclude-multiple-patterns-from-patchDirectory/src/main/patches/second.patch b/src/it/exclude-multiple-patterns-from-patchDirectory/src/main/patches/second.patch
new file mode 100644
index 0000000..0ae1671
--- /dev/null
+++ b/src/it/exclude-multiple-patterns-from-patchDirectory/src/main/patches/second.patch
@@ -0,0 +1,25 @@
+#
+#  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.
+#
+Index: target/test2.txt
+===================================================================
+--- target/test2.txt	(revision 0)
++++ target/test2.txt	(revision 0)
+@@ -0,0 +1 @@
++This is a test.
+
diff --git a/src/it/exclude-multiple-patterns-from-patchDirectory/verify.bsh b/src/it/exclude-multiple-patterns-from-patchDirectory/verify.bsh
new file mode 100644
index 0000000..198920e
--- /dev/null
+++ b/src/it/exclude-multiple-patterns-from-patchDirectory/verify.bsh
@@ -0,0 +1,45 @@
+/*
+    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.util.*;
+
+try
+{
+    File testFile = new File( basedir, "target/test.txt" );
+    if ( testFile.isFile() )
+    {
+        System.err.println( "File must not exist: " + testFile );
+        return false;
+    }
+
+    testFile = new File( basedir, "target/test2.txt" );
+    if ( testFile.isFile() )
+    {
+        System.err.println( "File must not exist: " + testFile );
+        return false;
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;
diff --git a/src/it/exclude-patches-from-patchDirectory/pom.xml b/src/it/exclude-patches-from-patchDirectory/pom.xml
index 6e5b626..51722e0 100644
--- a/src/it/exclude-patches-from-patchDirectory/pom.xml
+++ b/src/it/exclude-patches-from-patchDirectory/pom.xml
@@ -38,7 +38,9 @@
 
         <configuration>
           <targetDirectory>${basedir}</targetDirectory>
-          <excludePattern>se*.patch</excludePattern>
+          <excludes>
+            <exclude>se*.patch</exclude>
+          </excludes>
           <!-- enables reading of patches from src/main/patches -->
           <naturalOrderProcessing>true</naturalOrderProcessing>
         </configuration>
diff --git a/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
index 5f497e2..112b5ad 100644
--- a/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
+++ b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java
@@ -27,6 +27,7 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -238,14 +239,14 @@ public class ApplyMojo
     private boolean binary;
 
     /**
-     * List of ANT-style exclude patterns separated by a comma. These patterns are used to exclude patch files found
+     * List of ANT-style exclude patterns. These patterns are used to exclude patch files found
      * in the {@link ApplyMojo#patchDirectory}. These exclude patterns does not apply to a static defined list of
      * {@link ApplyMojo#patches}.
      *
      * @since 1.3
      */
     @Parameter
-    private String excludes;
+    private List excludes;
 
     /**
      * Apply the patches. Give preference to patchFile over patchSourceDir/patches, and preference to originalFile over
@@ -288,12 +289,14 @@ public class ApplyMojo
                         + patchDirectory );
                 }
 
+                String excludePatterns = "";
                 if ( excludes != null )
                 {
-                    getLog().info( "Exclude pattern: " + excludes);
+                    excludePatterns = StringUtils.join( excludes.iterator(), "," );
+                    getLog().info( "Exclude pattern: " + excludePatterns );
                 }
 
-                List foundPatchFiles = FileUtils.getFileNames( patchDirectory, "*", excludes, false );
+                List foundPatchFiles = FileUtils.getFileNames( patchDirectory, "*", excludePatterns, false );
 
                 patchesToApply = findPatchesToApply( foundPatchFiles, patchDirectory );