Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven WAR plugin skips resources?

Tags:

maven

war

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>
    </configuration>
</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]
like image 261
Michael Borgwardt Avatar asked May 13 '11 14:05

Michael Borgwardt


2 Answers

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.

like image 90
Michael Borgwardt Avatar answered Oct 29 '22 04:10

Michael Borgwardt


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>
like image 28
vkraemer Avatar answered Oct 29 '22 02:10

vkraemer