Skip to content

Instantly share code, notes, and snippets.

@AndersDJohnson
Last active June 5, 2019 13:37
Show Gist options
  • Save AndersDJohnson/f22cbdfc6ed19ca4fe4c to your computer and use it in GitHub Desktop.
Save AndersDJohnson/f22cbdfc6ed19ca4fe4c to your computer and use it in GitHub Desktop.
Maven Copy Dependencies
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<!--<packaging>war</packaging>-->
<profiles>
<profile>
<!--
Enable this profile to copy Maven dependencies to project locations.
-->
<id>copy-dependencies</id>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!--
Copies test dependencies.
-->
<execution>
<id>copy-test-dependencies</id>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>test</includeScope>
<outputDirectory>build/lib</outputDirectory>
</configuration>
</execution>
<!--
Copies sources for test dependencies.
-->
<execution>
<id>copy-test-dependencies-sources</id>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>test</includeScope>
<classifier>sources</classifier>
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
<outputDirectory>build/libsrc</outputDirectory>
</configuration>
</execution>
<!--
Copies compile and runtime dependencies.
-->
<execution>
<id>copy-dependencies</id>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>compile</includeScope>
<includeScope>runtime</includeScope>
<outputDirectory>WebContent/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
<!--
Copies sources compile and runtime dependencies.
-->
<execution>
<id>copy-dependencies-sources</id>
<phase>process-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>test</includeScope>
<classifier>sources</classifier>
<failOnMissingClassifierArtifact>false</failOnMissingClassifierArtifact>
<outputDirectory>build/libsrc</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<directory>WebContent/WEB-INF</directory>
<resources>
<resource>
<directory>src/config</directory>
<targetPath>.</targetPath>
<includes>
<include>**/*</include>
</includes>
</resource>
</resources>
</build>
<dependencies>
<!-- ... -->
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment