You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2024/07/11 19:41:49 UTC

(maven-war-plugin) branch master updated: [MWAR-470] - Support user property for packagingExcludes

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 35cbf56  [MWAR-470] - Support user property for packagingExcludes
35cbf56 is described below

commit 35cbf56aba8b4392a8bb4bd4a88e4efa78227b3d
Author: frode-carlsen <23...@users.noreply.github.com>
AuthorDate: Wed Aug 2 10:40:02 2023 +0200

    [MWAR-470] - Support user property for packagingExcludes
---
 .../java/org/apache/maven/plugins/war/WarMojo.java |  2 +-
 .../org/apache/maven/plugins/war/WarMojoTest.java  | 37 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/maven/plugins/war/WarMojo.java b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
index 861a10b..6b46c18 100644
--- a/src/main/java/org/apache/maven/plugins/war/WarMojo.java
+++ b/src/main/java/org/apache/maven/plugins/war/WarMojo.java
@@ -82,7 +82,7 @@ public class WarMojo extends AbstractWarMojo {
      *
      * @since 2.1-alpha-2
      */
-    @Parameter
+    @Parameter(property = "maven.war.packagingExcludes")
     private String packagingExcludes;
 
     /**
diff --git a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java
index 8577299..d85a4c7 100644
--- a/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/war/WarMojoTest.java
@@ -131,6 +131,43 @@ public class WarMojoTest extends AbstractWarMojoTest {
                 new String[] {"org/web/app/last-exile.jsp"});
     }
 
+    public void testSimpleWarPackagingExcludesWithRegEx() throws Exception {
+        String testId = "SimpleWarPackagingExcludesWithRegEx";
+        MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();
+        String outputDir = getTestDirectory().getAbsolutePath() + "/" + testId + "-output";
+        File webAppDirectory = new File(getTestDirectory(), testId);
+        WarArtifact4CCStub warArtifact = new WarArtifact4CCStub(getBasedir());
+        String warName = "simple";
+        File webAppSource = createWebAppSource(testId);
+        File classesDir = createClassesDir(testId, true);
+        File xmlSource = createXMLConfigDir(testId, new String[] {"web.xml"});
+
+        project.setArtifact(warArtifact);
+        this.configureMojo(mojo, new LinkedList<>(), classesDir, webAppSource, webAppDirectory, project);
+        setVariableValueToObject(mojo, "outputDirectory", outputDir);
+        setVariableValueToObject(mojo, "warName", warName);
+        mojo.setWebXml(new File(xmlSource, "web.xml"));
+        setVariableValueToObject(mojo, "packagingExcludes", "%regex[.+/last-exile.+]");
+
+        mojo.execute();
+
+        // validate jar file
+        File expectedJarFile = new File(outputDir, "simple.war");
+        assertJarContent(
+                expectedJarFile,
+                new String[] {
+                    "META-INF/MANIFEST.MF",
+                    "WEB-INF/web.xml",
+                    "pansit.jsp",
+                    "META-INF/maven/org.apache.maven.plugin.test/maven-war-plugin-test/pom.xml",
+                    "META-INF/maven/org.apache.maven.plugin.test/maven-war-plugin-test/pom.properties"
+                },
+                new String[] {
+                    null, mojo.getWebXml().toString(), null, null, null,
+                },
+                new String[] {"org/web/app/last-exile.jsp"});
+    }
+
     public void testClassifier() throws Exception {
         String testId = "Classifier";
         MavenProject4CopyConstructor project = new MavenProject4CopyConstructor();