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!
Introduction File filtering is used to substitute variable fields from inside a file to their represented values. For the Assembly Plugin, and most Maven filtering procedures, these variables are enclosed between $ { and }. For example, before a file is filtered, it contains $ {project.artifactId}.
A generic way to copy arbitrary files is to utilize Maven Wagon transport abstraction. It can handle various destinations via protocols like file, HTTP, FTP, SCP or WebDAV. There are a few plugins that provide facilities to copy files through the use of Wagon. Most notable are: There is the deploy-file goal.
By default, Maven generated archives include the META-INF/maven directory, which contains the pom.xml file used to build the archive, and a pom.properties file that includes some basic properties in a small, easier to read format.
Here is example of Maven Copy Resources Example with from one location to another location, include files, exclude files. 1. Maven Copy Resource from one location to another location 2. Maven copy resource with exclude files 3. Maven copy resource with include files 4. Maven copy resource with include + exclude files Was this post helpful? 1.
Have you ever thought about the maven-dependency-plugin which has a good support for unpacking archives.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With