[ https://issues.apache.org/jira/browse/MPATCH-20?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16386214#comment-16386214 ]
ASF GitHub Bot commented on MPATCH-20: -------------------------------------- matthiasbalke closed pull request #1: added support for excludePattern (fixes MPATCH-20) URL: https://github.com/apache/maven-patch-plugin/pull/1 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/src/it/cant-exclude-patches-from-patches/pom.xml b/src/it/cant-exclude-patches-from-patches/pom.xml new file mode 100644 index 0000000..e13970e --- /dev/null +++ b/src/it/cant-exclude-patches-from-patches/pom.xml @@ -0,0 +1,67 @@ +<!-- + 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> + + <groupId>test</groupId> + <artifactId>cant-exclude-patches-from-patches</artifactId> + <name>cant-exclude-patches-from-patches</name> + <version>1.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-patch-plugin</artifactId> + <version>@pom.version@</version> + + <configuration> + <targetDirectory>${basedir}</targetDirectory> + <!-- this exclude does not work, as it is only excluding files from patchDirectory --> + <excludePattern>se*.patch</excludePattern> + <!-- both patches should be executed --> + <patches> + <patch>first.patch</patch> + <patch>second.patch</patch> + </patches> + </configuration> + + <executions> + <execution> + <id>apply-patches</id> + + <phase>initialize</phase> + + <goals> + <goal>apply</goal> + </goals> + + <configuration> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/cant-exclude-patches-from-patches/src/main/patches/first.patch b/src/it/cant-exclude-patches-from-patches/src/main/patches/first.patch new file mode 100644 index 0000000..5c6f211 --- /dev/null +++ b/src/it/cant-exclude-patches-from-patches/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/cant-exclude-patches-from-patches/src/main/patches/second.patch b/src/it/cant-exclude-patches-from-patches/src/main/patches/second.patch new file mode 100644 index 0000000..0ae1671 --- /dev/null +++ b/src/it/cant-exclude-patches-from-patches/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/cant-exclude-patches-from-patches/verify.bsh b/src/it/cant-exclude-patches-from-patches/verify.bsh new file mode 100644 index 0000000..dd3f3b8 --- /dev/null +++ b/src/it/cant-exclude-patches-from-patches/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( "Missing test file: " + testFile ); + return false; + } + + testFile = new File( basedir, "target/test2.txt" ); + if ( !testFile.isFile() ) + { + System.err.println( "Missing test file: " + 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 new file mode 100644 index 0000000..6e5b626 --- /dev/null +++ b/src/it/exclude-patches-from-patchDirectory/pom.xml @@ -0,0 +1,63 @@ +<!-- + 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> + + <groupId>test</groupId> + <artifactId>exclude-patches-from-patchDirectory</artifactId> + <name>exclude-patches-from-patchDirectory</name> + <version>1.0-SNAPSHOT</version> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + </properties> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-patch-plugin</artifactId> + <version>@pom.version@</version> + + <configuration> + <targetDirectory>${basedir}</targetDirectory> + <excludePattern>se*.patch</excludePattern> + <!-- enables reading of patches from src/main/patches --> + <naturalOrderProcessing>true</naturalOrderProcessing> + </configuration> + + <executions> + <execution> + <id>apply-patches</id> + + <phase>initialize</phase> + + <goals> + <goal>apply</goal> + </goals> + + <configuration> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/src/it/exclude-patches-from-patchDirectory/src/main/patches/first.patch b/src/it/exclude-patches-from-patchDirectory/src/main/patches/first.patch new file mode 100644 index 0000000..5c6f211 --- /dev/null +++ b/src/it/exclude-patches-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-patches-from-patchDirectory/src/main/patches/second.patch b/src/it/exclude-patches-from-patchDirectory/src/main/patches/second.patch new file mode 100644 index 0000000..0ae1671 --- /dev/null +++ b/src/it/exclude-patches-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-patches-from-patchDirectory/verify.bsh b/src/it/exclude-patches-from-patchDirectory/verify.bsh new file mode 100644 index 0000000..7be8344 --- /dev/null +++ b/src/it/exclude-patches-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( "Missing test file: " + 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/main/java/org/apache/maven/plugin/patch/ApplyMojo.java b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java index 2066b8a..83da555 100644 --- a/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java +++ b/src/main/java/org/apache/maven/plugin/patch/ApplyMojo.java @@ -237,6 +237,9 @@ @Parameter( defaultValue = "false" ) private boolean binary; + @Parameter + private String excludePattern; + /** * Apply the patches. Give preference to patchFile over patchSourceDir/patches, and preference to originalFile over * workDir. @@ -278,7 +281,12 @@ public void execute() + patchDirectory ); } - List foundPatchFiles = FileUtils.getFileNames( patchDirectory, "*", null, false ); + if ( excludePattern != null ) + { + getLog().info( "Exclude pattern: " + excludePattern ); + } + + List foundPatchFiles = FileUtils.getFileNames( patchDirectory, "*", excludePattern, false ); patchesToApply = findPatchesToApply( foundPatchFiles, patchDirectory ); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > support exclude pattern > ----------------------- > > Key: MPATCH-20 > URL: https://issues.apache.org/jira/browse/MPATCH-20 > Project: Maven Patch Plugin > Issue Type: New Feature > Affects Versions: 1.2, 1.3 > Reporter: Matthias Balke > Priority: Major > > The maven-patch-plugin should provide a feature to configure an exclude > pattern which is applied, when searching for patch files within > {{patchDirectory}}. > > I'll provide a PR on GitHub for this feature. -- This message was sent by Atlassian JIRA (v7.6.3#76005)