If I add the following property in my POM, the maven-war-plugin
uses it correctly:
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
However if I add the following property the plugin ignores it (the generated WAR has the default name, i.e. artifactId-version):
<properties>
<war.warName>${project.artifactId}</war.warName>
</properties>
Here are two excerpts from the maven-war-plugin
documentation:
warName:
- The name of the generated WAR.
- Type: java.lang.String
- Required: Yes
- User Property: war.warName
- Default: ${project.build.finalName}
failOnMissingWebXml:
- Whether or not to fail the build if the web.xml file is missing. Set to false if you want you WAR built without a web.xml file. This may be useful if you are building an overlay that has no web.xml file.
- Type: boolean
- Since: 2.1-alpha-2
- Required: No
- User Property: failOnMissingWebXml
- Default: true
(Source: https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html)
Why is the behavior different between failOnMissingWebXml
and war.warName
?
Also, if other plugins can use the value ${project.build.sourceEncoding}
why can't maven-war-plugin
use the value of ${project.build.finalName}?
<properties>
<!-- plugins use these values correctly -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- not "found" by maven-war-plugin -->
<war.warName>${project.artifactId}</war.warName>
<project.build.finalName>${project.artifactId}</project.build.finalName>
</properties>
Thanks a lot! :)
EDIT: Since the version 2.4 of maven-war-plugin
war.warName works as expected, however I still don't understand why setting project.build.finalName
doesn't work.