Using Maven war plugin, I generate WAR which includes following directory:
META-INF -- maven -- com.abc.def -- myServlet -- pom.xml -- pom.properties
In release, I want to exclude this maven directory. How can I do that?
I tried latest maven-war-plugin (2.1-beta-1), it has configuration "packagingExcludes", but it doesn't work as I wish.
Any suggestions?
Open the dependency POM and find the transitive dependency you want to exclude. Copy groupId and artifactId . In your project POM, underneath your active dependency, enter exclusions and using code completion paste the copied info of the dependency you want to exclude.
It is possible to include or exclude certain files from the WAR file, by using the <packagingIncludes> and <packagingExcludes> configuration parameters. They each take a comma-separated list of Ant file set patterns.
packagingExcludes: The comma separated list of tokens to exclude from the WAR before packaging. With packagingExcludes, the tokens are completely excluded from the final war file. With warSourceExcludes, the tokens are just ignored when copying the war directory into the war file.
I'm not sure but I think that the Maven Archiver (which is mainly used by plugins to handle packaging) can be configured to achieve this.
About the <addMavenDescriptor>
element, the Maven Archiver Reference says:
Whether the generated archive will contain these two Maven files:
- The pom file, located in the archive in
META-INF/maven/${groupId}/${artifactId}/pom.xml
- A
pom.properties
file, located in the archive inMETA-INF/maven/${groupId}/${artifactId}/pom.properties
The default value is true.
So a pom configured like this should do the trick:
<project> ... <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0</version> <configuration> <archive> <addMavenDescriptor>false</addMavenDescriptor> </archive> </configuration> </plugin> ... </plugins> </build> ... </project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With