Maven WAR插件跳过资源?

8

现在这真是太奇怪了:我有许多想要复制到WAR中的文件夹/文件,以下是POM的相关部分:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <webResources>
        <resource><directory>../common-web-content/src/main/resources</directory></resource>
        <resource><directory>../pqm-web-content/src/main/resources</directory><filtering>true</filtering></resource>
        <resource><directory>../common-presentation/src/main/webapp</directory></resource>
        <resource>
          <directory>${project.basedir}/src/main/webapp/WEB-INF</directory>
          <includes><include>web.xml</include></includes>
          <filtering>true</filtering>
          <targetPath>WEB-INF</targetPath>
        </resource>
      </webResources>
    </configuration>
</plugin>

路径都是正确的并且经过了双重检查。然而,第二个资源文件夹未被复制 - 在这种情况下是pqm-web-content,但即使我改变顺序,缺失的总是第二个。但是没有错误消息:

[INFO] Processing war project
[INFO] Copy webapp webResources[D:\pqmGF\pqm\pqm-war\../common-web-content/src/main/resources] to[D:\pqmGF\pqm\pqm-war\target\pqm-war-3.3.5.0-SNAPSHOT]
[INFO] Copy webapp webResources[D:\pqmGF\pqm\pqm-war\../pqm-web-content/src/main/resources] to[D:\pqmGF\pqm\pqm-war\target\pqm-war-3.3.5.0-SNAPSHOT]
[INFO] Copy webapp webResources[D:\pqmGF\pqm\pqm-war\../common-presentation/src/main/webapp] to[D:\pqmGF\pqm\pqm-war\target\pqm-war-3.3.5.0-SNAPSHOT]
[INFO] Copy webapp webResources[D:\pqmGF\pqm\pqm-war/src/main/webapp/WEB-INF] to [D:\pqmGF\pqm\pqm-war\target\pqm-war-3.3.5.0-SNAPSHOT]
[INFO] Webapp assembled in[7891 msecs]

你尝试过移除过滤标签吗? - user454043
3个回答

2

显然,这是Maven的一个bug或者Maven 3.0.3和WAR插件之间不兼容导致的问题。切换到Maven 2.2.1后,问题得到了正确解决。


2
我快速搜索了Maven-WAR JIRA,没有看到任何类似的问题。您可能需要提交一个问题,以便相关人员看到并解决它。 - vkraemer

1

你考虑过像这样做吗...

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
      <webResources>
        <resource><directory>../common-web-content/src/main/resources</directory></resource>
        <!-- this next line is repeated because of a problem I am having with the maven-war-plugin -->
        <resource><directory>../pqm-web-content/src/main/resources</directory><filtering>true</filtering></resource>
        <resource><directory>../pqm-web-content/src/main/resources</directory><filtering>true</filtering></resource>
        <resource><directory>../common-presentation/src/main/webapp</directory></resource>
        <resource>
          <directory>${project.basedir}/src/main/webapp/WEB-INF</directory>
          <includes><include>web.xml</include></includes>
          <filtering>true</filtering>
          <targetPath>WEB-INF</targetPath>
        </resource>
      </webResources>
    </configuration>
</plugin>

我会接受这个作为创意,尽管由于某些原因,原始问题已经消失,所以我无法确定它是否可以解决问题。 - Michael Borgwardt

0

我在使用maven-war-plugin版本2.6时遇到了类似的问题,当从两个连续的目录中构建时,第一个目录的内容不会被复制到最终构建中。 问题是我在单个<resource>标签中有两个<directory>标签。只有一个<resource>和一个<directory>标签的情况下可以正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接