Nelz's Blog

Mah blogginess

Maven Tomcat Plugin

Maven. It is both fantastic, and stress-inducing. And more than just Maven itself, there is a whole community of Maven plugins which are just as frustrating.

Take the Maven Tomcat Plugin for example. It sounds so nice to just type “mvn tomcat:run” in your webapp module, and have it automagically run, dynamically loading any JSP changes. But, if you have a non-trivial webapp, you probably need to send in some system properties.

Let’s pretend that I require the following command-line parameters passed to Tomcat on the command line:

-Dexample.value.1=alpha -Dexample.value.2=beta

How would I send that in to the Tomcat plugin? Well, the documentation says there is a “systemProperties” element where you can sent them in. But what is the format?

Is the format perhaps like the Surefire Plugin?

<systemProperties>
  <property>
    <name>example.value.1</name>
    <value>alpha</value>
  </property>
  <property>
    <name>example.value.2</name>
    <value>beta</value>
  </property>
</systemProperties>

Or perhaps the format is like that of the Jetty Plugin?

<systemProperties>
  <systemProperty>
    <name>example.value.1</name>
    <value>alpha</value>
  </systemProperty>
  <systemProperty>
    <name>example.value.2</name>
    <value>beta</value>
  </systemProperty>
</systemProperties>

Nope. The format is like neither of those. It’s like this:

<systemProperties>
  <example.value.1>alpha</example.value.1>
  <example.value.2>beta</example.value.2>
</systemProperties>

I’ll admit that this format is a bit less verbose. But why, in the name of all that is holy, does it have to have it’s own 1-off syntax?!? And can you find this documented anywhere else? I was sure challenged finding it.

This is the kind of non-documentation and irregularity that gives Maven a bad name and keeps my blood pressure high.

UPDATE (1 Nov 09): As she says in the comments, Kathy actually took the time to submit a ticket to the Maven Tomcat Plugin maintainers, rather than going with my tactic of passively bitching. And today I get notified by herion that the suggestion was taken and there is now public documentation added about these properties.