Search code examples
maventomcat8webdeploy

Setting application-specific properties on deploy by maven


I would like to deploy java app twice to one tomcat server, each time with different environment properties.

I would like to find a way like

mvn tomcat7:deploy -Denvironment=local

I don't mind using other maven plugin.

With no need to change files after deploy. Is it somehow possible? Thank you for you answer.


Solution

  • I used little workaround. I created different profiles which I use to update application property.

    example: In my POM I have:

    <profiles>
        <profile>
            <id>local</id>
            <properties>
                <environment>local</environment>
                ....
            </properties>
        </profile>
    

    and in application.property file I have

    environment=@environment@
    

    (That @ are correct! )

    This way I can deploy my app with defined environment by using command

    mvn -P local tomcat7:deploy 
    

    and use environment variable anywhere else as ${environment}