A Developer's Diary

Jan 12, 2013

Maven - Copying artifacts to specific folder

Above is the directory structure of web application generated using maven. Use maven-dependency-plugin for copying artifacts to desired folder under WEB-INF directory

The application has only one dependent artifact item as shown in the pom.xml below
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <name>MyWeb Maven Webapp</name>

Use maven-dependency-plugin to copy an artifact to a specific directory. Add the lines below to your pom.xml under build tag to include the dependency plugin and run it as part of the mvn package command. Make sure you have also defined the copy goal.

Note: The plugins tag should NOT be within pluginManagement The pluginManagement tag is a way to share the same plugin configuration across all your project modules whereas plugins tag is an actual invocation of the plugin.

No comments :

Post a Comment