Search code examples
javatestingmaven-2continuous-integrationmaven-cargo

Howto pass Java system properties to maven-cargo container


I'm preparing a maven2 web project for continuous integration. I use the maven cargo plugin to automatically deploy the WAR to Tomcat6x before running integration tests.

My code depends on some system properties which are set with MAVEN_OPTS=-Dfoo=bar. Unfortunately these properties are missing when the application is deployed to Tomcat:

System.getProperty("foo"); // null, when deployed to container by maven-cargo

How can I pass these properties to Tomcat?


Solution

  • You should be able to do this by using the systemProperties tag in the container definition of the plugin:

          <container>
            [...]
          <systemProperties>
            <MAVEN_OPTS>-Dfoo=bar</MAVEN_OPTS>
          </systemProperties>
        </container>
    

    Or you can set this in a setenv.sh (on linux) file in your $CATALINA_HOME/bin/ directory. If this file does not exist you should create it and add the following line:

    MAVEN_OPTS=-Dfoo=bar
    

    Hope this helps.