Maven: include folder in resource folder in war assembly

I have a folder called extra-jars in src / main / rescource, but how can I include them in the assembly? I want them to be placed in the lib folder along with the other banks. I tried turning them on, but that didn't work.

+5
jar maven web-applications build-process
source share
2 answers

For banners that are not distributed by the Maven repository, the easiest way is to place additional banks in the src/main/webapp/WEB-INF/lib your project. Maven, by convention, will include everything under src/main/webapp in the final military artifact.

An additional method is to use the Maven War Plugin . It has the ability to add additional files to the final artifact of the war, although the configuration of the plugin.

In the POM build section, add something like the following:

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <webResources> <resource> <directory>src/main/resource/extra-jars</directory> <includes> <include>*.jar</include> </includes> <targetPath>WEB-INF/lib</targetPath> </resource> </webResources> </configuration> </plugin> </plugins> </build> 

The <configuration> section is the key to adding additional files.

  • The <directory> element defines the location of the resource source. The path refers to pom.xml .
  • The <includes> element determines which files found in the above directory should be included.
  • The <targetPath> element defines the destination directory in the WAR to which the files are copied.
+4
source share

These jars should be added as dependencies on Maven, and not be copied to the lib folder. This is the very thing Maven is for.

+2
source share

All Articles