Monday, April 23, 2012

Maven assembly: copy from specific sub-folder of dependency

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).





No comments:

Post a Comment