You most probably don't need copy-dependencies
but unpack
. Check the official example for further details.
The following example:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>2.1.4</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes/myfolder</outputDirectory>
<includes>META-INF/resources/**/*.*</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Will copy under ${project.build.directory}/classes/myfolder
the content of META-INF/resources
which is basically the webjars
folder. However you would also get the META-INF/resources
tree structure.
To achieve exactly your intent (copy only a subfolder content of a dependency to a certain folder) you need to use two plugins: the maven-dependency-plugin
and the maven-resources-plugin
as following:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>2.1.4</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/tmp</outputDirectory>
<includes>META-INF/resources/**/*.*</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/myfolder</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/tmp/META-INF/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
The maven-dependency-plugin
would copy our desired directory tree to the target\tmp
folder, then the maven-resources-plugin
would copy only the subfolder we want to the final directory.
Please note both plugins will be executed during the install
phase but their declaration order it really important to have the final desired outcome.