Issue
I have a very specific requirement of our build infrastructure to copy some contents of another JAR dependency to a specific sub-folder of my web-application. We're using maven-assembly-plugin, and a natural way to do this is to use <dependencySet>
along with <unpackOptions>
.
The code sample (in assembly descriptor) I have looks as following:
<dependencySet>
<unpack>true</unpack>
<scope>runtime</scope>
<useProjectArtifact>false</useProjectArtifact>
<includes>
<include>my.group:artifact:jar</include>
</includes>
<unpackOptions>
<includes>
<include>subfolder/config.xml</include>
</includes>
</unpackOptions>
<outputDirectory>WEB-INF/otherfolder</outputDirectory>
</dependencySet>
The problem is that I can't figure out how to specify that I only want to copy just a single file artifact.jar/subfolder/config.xml
to a target WEB-INF/otherfolder
. The actual result is WEB-INF/otherfolder/subfolder/config.xml
. As you can see, /subfolder
gets appended to a final path. Is there any way to change the <include>
expression so that /subfolder
doesn't get appended?
Thanks in advance!
Solution
Browsing through source reveals that this is not possible via maven-assembly plug-in. It gets all includes that are specified in assembly descriptor, and then passes this information to Plexus archiver which is used through multiple stages. Include patterns are passed to Plexus archiver as well, and then it obviously performs 'unpack' conserving directory structure.
Answered By - Art Licis
Answer Checked By - Mary Flores (JavaFixing Volunteer)