2

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?

Olvagor
  • 2,332
  • 5
  • 25
  • 26

2 Answers2

7

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.

maskefjes
  • 340
  • 1
  • 3
  • 8
  • Ah, thanks! I tried using but I must have made something wrong. To set "foo=bar" the XML looks like: [...] bar – Olvagor Jan 29 '09 at 09:23
2

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

<container>
  <systemProperties>
    <foo>bar</foo>
  </systemProperties>
</container>

this is equivalent to pass -Dfoo=bar in command line or in another option.

user787242
  • 21
  • 1