Maven assembly: copy from specific sub-folder of dependency
maven, maven-assembly-plugin
Solution
You should be able to use the Maven Dependency plugin to do this, with the unpack goal: http://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-database-scripts</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>myGroup</groupId>
<artifactId>myArtifact</artifactId>
<version>1.0</version>
<type>war</type>
<overWrite>true</overWrite>
<includes>...</includes>
<outputDirectory>…</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Problem
I'm using Maven assembly plugin to build a WAR of our product (previously done by Ant). As there're many leftovers of Apache Ant, there's one specific requirement that would make build process easier: copy specific sub-folder of dependency (e.g., jar or war resource) to a specific target sub-folder. So far I learned that Assembly descriptors allow to specify `<outputDirectory>`, but is there's any chance to specify a `<sourceDirectory>`? E.g., I want to apply this rule for one single WAR or JAR type dependency. Consider this example of assembly descriptor fragment (not 100% accurate): ``` <dependencySet> <unpack>true</unpack> <scope>runtime</scope> <useProjectArtifact>false</useProjectArtifact> <includes> <include>my-specific-dependency:war</include> </includes> <outputDirectory>WEB-INF/myresources</outputDirectory> </dependencySet> ``` I want to say that I want to copy some folder from my-specific-dependency:war to WEB-INF/myresources. EDIT NB: I'm aware that this is not a very correct requirement as we shouldn't know what's inside an artifact, the correct way would be declaring to extract the whole artifact to the target directory (neat declarative approach).