How to set display name in maven-war-plugin for web.xml

How to determine web.xml display name via maven using maven-war plugin?

The maven-ear-plugin has a displayName option for setting the display-name attribute EAR / application.xml.

Wrong approach? Just install it manually in web.xml?

+4
source share
2 answers

Much easier ...

<plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <filteringDeploymentDescriptors>true</filteringDeploymentDescriptors> </configuration> </plugin> 

see filteringDeploymentDescriptors documentation. It is available since 2.1, but is disabled by default.

+4
source

You need to use the Maven web resource filtering approach. Define the following configuration in your maven-war plugin:

 <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.2</version> <configuration> <webResources> <resource> <directory>src/main/webapp/WEB-INF/</directory> <targetPath>WEB-INF</targetPath> <includes><include>web.xml</include></includes> <filtering>true</filtering> </resource> </webResources> </configuration> </plugin> 

And in your web.xml you can use any properties defined in your pom.xml. For example, you can use:

 <display-name>${project.name} - ${project.version}</display-name> 

This will display as

 <display-name>My Awesome Webapp - 1.0.0-SNAPSHOT</display-name> 

If you use Eclipse, you will need m2e-wtp (look at the screencast for filtering web resources on the home page)

+8
source

Source: https://habr.com/ru/post/1411302/


All Articles