maven-war-plugin include subdirectories

1k views Asked by At

I'm having an issue where I need to include some folders in my Maven generated WAR using the maven-war-plugin but it is only including the files in the directory and not the sub-directories as well. This is how I have configured the war-plugin within the pom.

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
             <webXml>WEB-INF\web.xml</webXml>  
                <webResources>
                    <resource>
                        <directory>icons</directory>
                        <targetPath>icons</targetPath>
                    </resource>
                    <resource>
                        <directory>data</directory>
                        <targetPath>data</targetPath>
                    </resource>
                </webResources>
            </configuration>

        </plugin>

This generates the folder data in the war root like so:

data
-> file1.txt

but the source folder contains subdirectories which I would like copied as well like so.

data
->english
    --> english.txt
-> file1.txt

Is there a way to do this?

1

There are 1 answers

0
khmarbaise On BEST ANSWER

You can force maven-war-plugin to add empty folders if you say explicitly by using the appropriate configuration parameter:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <includeEmptyDirectories>true</includeEmptyDirectories>
          ..
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>