Maven 2 Maven WAR插件在<;中运行时未读取配置;执行>;标签

Maven 2 Maven WAR插件在<;中运行时未读取配置;执行>;标签,maven-2,war,Maven 2,War,我正试图让Maven使用WAR插件执行几次执行。只要按以下方式定义,它就可以正常工作: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>1.0</version> <configuration> (...)

我正试图让Maven使用WAR插件执行几次执行。只要按以下方式定义,它就可以正常工作:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
<version>1.0</version>
    <configuration>
    (...)
    </configuration>

org.apache.maven.plugins
maven战争插件
1
(...)

但不是以下面的方式

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>1.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <configuration>
            (...)
            </configuration>
        </execution>
    </executions>
</plugin>

org.apache.maven.plugins
maven战争插件
1
包裹
(...)

其中Maven找不到我在
标记中定义的任何资源。我是否遗漏了任何重要的内容,和/或是否有更好的方法在单个构建中构建多个WAR文件?

第二个版本仅将配置应用于您指定的阶段。我现在无法确认这一点,但我猜它没有被应用,因为您尚未指定要应用到的配置的目标

如果将
war
目标定义添加到执行中,它是否得到应用?像这样:

<executions>
    <execution>
        <phase>package</phase>
        <goals>
          <goal>war</goal>
        </goals>
        <configuration>
        (...)
        </configuration>
    </execution>
</executions>

包裹
战争
(...)

我没有看到如何关闭默认情况下生成的war,但您可以在
元素之外使用一种配置,在元素内部使用其余配置:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1-beta-1</version>
    <configuration>
      <classifier>with-junk</classifier>
      <!-- temp directory that the webapp is assembled in (each must be different) -->
      <webappDirectory>${project.build.directory}/build-with-junk</webappDirectory>
      <webResources>
        <resource>
          <directory>junk</directory>
          <includes>
            <include>**/*</include>
          </includes>
        </resource>
      </webResources>
    </configuration>
    <executions>
      <execution>
        <id>add-other-junk</id>
        <phase>package</phase>
        <goals>
          <goal>war</goal>
        </goals>
        <!-- exclude prior configuration -->
        <inherited>false</inherited>
        <configuration>
          <classifier>with-other-junk</classifier>
          <webappDirectory>${project.build.directory}/build-other-junk</webappDirectory>
          <webResources>
            <resource>
              <directory>other-junk</directory>
              <includes>
                <include>**/*</include>
              </includes>
            </resource>
          </webResources>
        </configuration>
      </execution>
    </executions>
  </plugin>

org.apache.maven.plugins
maven战争插件
2.1-β-1
垃圾
${project.build.directory}/build with junk
废旧物品
**/*
添加其他垃圾
包裹
战争
假的
与其他垃圾
${project.build.directory}/build-other-junk
其他垃圾
**/*

对我来说,这构建了
artifact-0.1-with-junk.war
artifact-0.1-with-other-junk.war
,并且都包含了正确的文件。

好主意,但没有交易:/谢谢。你解决过这个问题吗?我也在为同样的问题挣扎。不,从来没有解决过。事实上,我甚至不确定这是否可能。结果我不得不创建多个项目。有人解决了这个问题吗?也在为这个问题苦苦挣扎。