Skip to content

Commit

Permalink
[MWAR-470] - Support user property for packagingExcludes
Browse files Browse the repository at this point in the history
  • Loading branch information
frode-carlsen authored and slawekjaranowski committed Jul 11, 2024
1 parent 4f8a41e commit 35cbf56
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/org/apache/maven/plugins/war/WarMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class WarMojo extends AbstractWarMojo {
*
* @since 2.1-alpha-2
*/
@Parameter
@Parameter(property = "maven.war.packagingExcludes")
private String packagingExcludes;

/**
Expand Down
37 changes: 37 additions & 0 deletions src/test/java/org/apache/maven/plugins/war/WarMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,43 @@ public void testSimpleWarPackagingExcludeWithIncludesRegEx() throws Exception {
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();
Expand Down

0 comments on commit 35cbf56

Please sign in to comment.