Maven Tip
Jay Shaughnessy
jshaughn at redhat.com
Thu Dec 22 21:19:58 UTC 2011
During a recent JON build we hit a subtle problem in the maven poms.
It's something to watch out for
in your build maven plugin executions. In short, be very careful with
the placement of:
<configuration>
</configuration>
The maven plugin configuration element can be global to the plugin, or
local to an execution. If you
make it global be very sure it really should apply to all executions for
that plugin, in the chain of
poms for the module being built. In general the configuration should be
local to the execution.
Global Example:
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.1</version>
<executions>
<execution>
<id>my-repo-deletion</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>rm</executable>
<workingDirectory>${settings.localRepository}</workingDirectory>
<arguments>
<argument>-Rf</argument>
<argument>local/repo/thing</argument>
</arguments>
</configuration>
</plugin>
The problem here is that the global configuration may affect other
exec-maven-plugin executions in this or
other poms. In particular, the setting of the working directory is very
bad. This was the problem we hit
in out recent build.
Below is the way it should have been done, this configuration should be
local to the execution.
<plugin>
<artifactId>exec-maven-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<version>1.1</version>
<executions>
<execution>
<id>my-repo-deletion</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>rm</executable>
<workingDirectory>${settings.localRepository}</workingDirectory>
<arguments>
<argument>-Rf</argument>
<argument>local/repo/thing</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
-Jay
More information about the rhq-devel
mailing list