Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude pom.xml from Maven generated war?

Tags:

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?

like image 396
user179080 Avatar asked Sep 25 '09 14:09

user179080


People also ask

How do I add exclusions in POM XML?

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.

How do I exclude a war file?

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.

What is packagingExcludes?

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.


1 Answers

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 in META-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> 
like image 84
Pascal Thivent Avatar answered Sep 20 '22 11:09

Pascal Thivent