如何为Maven War插件配置多个输出目录? [英] How to configure more than one output directories for maven war plugin?

查看:497
本文介绍了如何为Maven War插件配置多个输出目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置了以下Maven War插件,但是我只创建了一个输出目录:

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>

如何配置该pligin以创建两个输出目录?

How can I configure this pligin to create two output directories for example?

推荐答案

首先,我强烈建议您不要将输出目录覆盖为"target/..."以外的其他内容. Maven遵循约定,虽然您可以将其配置为不遵循约定,但这确实意味着您必须将所有内容配置为远离常规位置.

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.

现在,如果要复制工作,只需添加第二个执行即可.为此,您将需要两个不同的执行ID.

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>

请注意,这实际上不会为单个war文件创建两个输出目录,而是将war两次打包两次到两个不同的输出目录.这是一个很好的细节,但有时可能很重要.

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.

这篇关于如何为Maven War插件配置多个输出目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆