Reputation:
I have configured the follwoing maven war plugin, but I created only one output directory:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<outputDirectory>C:\EclipseWorkspace\my_path\myPath2</outputDirectory>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
How can I configure this pligin to create two output directories for example?
Upvotes: 3
Views: 3697
Reputation: 70909
First, I highly recommend that you not override the output directory to be something other than "target/...". Maven follows conventions, and while you can configure it away from conventions, it does mean that you will have to configure everything away from the conventional locations.
Now, if you want to duplicate work, you simply add a second execution. To do so, you will need two different execution ids.
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
<execution>
<id>additional-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
And to have them have different configurations, add the configuration differences local to the execution.
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
... stuff specific to the first war ...
</configuration>
</execution>
<execution>
<id>additional-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
<configuration>
... stuff specific to the second war ...
</configuration>
</execution>
</executions>
Note that this will not really create two output directories for a single war file, but rather it will repackage the war twice to two different output directories. It's a fine detail, but occasionally it can be important.
Upvotes: 7