Multi-environment maven war generation

DevOps with Maven on WAR project

I’d like to let you an Maven snippet code for configure WAR project for different environments. Sometimes, we’re developing in a dev environment, but this project we’d like to run in another environments (cloud, server, etc).

This is a configuration profile

        <!-- There are 3 availabled (dev,nuvol,nuvolbeta), ie: mvn
            clean package -Dprofile=nuvol -->


  • Profile active by default (mvn clean package, will use dev environment)

  • Change environment variable with -Denv=dev (java runtime option)

  • All WEB-INF will be on src/main/webinf/

    • common: WEB-INF common files for all environment (DRY) : (Mandatory)

    • dev: WEB-INF files for dev environment : (Mandatory)

    • another_env_name: WEB-INF files for any environment if you want : (Optional)

  • All resources files (java resources) on src/main/resources

    • Same philosophy than WEB-INF configuration folder


  • This will ignore WEB-INF file on webapp/WEB-INF

  • If you want to import this project on Eclipse, you will add WEB-INF by han. (Project Properties→Deployment Assembly)