In maven – how to rename the output .war file based on the name of the profile in use

You’ve answered yourself correctly:

<profiles>
    <profile>
        <id>dev</id>
        <properties>
            <rp.build.warname>dev</rp.build.warname>
        </properties>
    </profile>
    <profile>
        <id>qa</id>
        <properties>
            <rp.build.warname>qa</rp.build.warname>
        </properties>
    </profile>
    <profile>
        <id>prod</id>
        <properties>
            <rp.build.warname>prod</rp.build.warname>
        </properties>
    </profile>
</profiles>

but there is a simpler way to redefine WAR name:

<build>
    <finalName>${rp.build.warname}-somearbitraryname</finalName>
    <!-- ... -->
</build>

No maven-war-plugin is needed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)