Total Pageviews

2017/12/09

[Maven] How to assign WAR file name in pom.xml

Problem
When I utilize maven to build WAR file, the WAR file name always suffix by version which define in pom.xml (i.e. StockQry-1.0.war).
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>StockQry</groupId>
    <artifactId>StockQry</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <!-- ignore plugins -->
        </plugins>
    </build>

    <dependencies>
        <!-- ignore dependencies -->
    </dependencies>

</project>
If I would like to have StockQry.war instead of StockQry-1.0.war, how to do it?


How-To
Add finalName in build tag, the updated pom.xml are the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>StockQry</groupId>
    <artifactId>StockQry</artifactId>
    <version>1.0</version>
    <packaging>war</packaging>
    <build>
        <finalName>StockQry</finalName>
        <sourceDirectory>src</sourceDirectory>
        <resources>
            <resource>
                <directory>src</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <!-- ignore plugins -->
        </plugins>
    </build>

    <dependencies>
        <!-- ignore dependencies -->
    </dependencies>

</project>


No comments: