开发者

maven WAR plugin skips resources?

开发者 https://www.devze.com 2023-03-05 11:56 出处:网络
Now this is downright bizarre: I have a number of folders/files I want copied into my WAR, here\'s the relevant part of the POM:

Now this is downright bizarre: I have a number of folders/files I want copied into my WAR, here's the relevant part of the 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>
    </configu开发者_Python百科ration>
</plugin>

The paths are all correct and double-checked. However, the second resource folder is not copied - in this case pqm-web-content, but even if I change the sequence, it's always the second one that's missing. But there is no error message:

[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]


Apparently, this is a bug of Maven or incompatibility between Maven 3.0.3 and the WAR Plugin. After switching to Maven 2.2.1, it works correctly.


have you considered doing something like this...

<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>


I had similar problem with maven-war-plugin version 2.6 when from two consecutive directories, first's contents would not be copied to final build. Problem was that I had two <directory> tags in single <resource> tag. Single <resource> with single <directory> tag worked fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消