Changing packaging based on active profile in pom

If you want to use profile you can use something like:

<?xml version="1.0" encoding="UTF-8"?>
<project>
    <modelVersion>4.0.0</modelVersion>
    ..
    <packaging>${packaging.type}</packaging>

    <profiles>
        <profile>
            <id>webapp</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <packaging.type>war</packaging.type>
            </properties>
        </profile>
        <profile>
            <id>batch</id>
            <properties>
                <packaging.type>jar</packaging.type>
            </properties>
                </profile>
          </profiles>
</project>

Leave a Comment