There is a jar file with following structure:
/--
|-dir1
|-file1
|-file2
|-file3
|-dir2
|-dir3
I set filter to take files only from dir1
<includes>dir1/*</includes>
it successfully takes files only from that directory, but in target directory copied files are placed in dir1, how can remove path from files that are copied and leave there only name. So file1
will be copied to target/file1
and not to target/dir1/file1
<build>
<finalName>${project.build.finalName}</finalName>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>version</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>target/natives</outputDirectory>
<includes>dir1/*</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
Support for the fileMappers tag was added in version 3.1.2 of the maven-dependency-plugin.
See official documentation Rewriting target path and file name
For example you could extract a nested .so file and place at a top level
<artifactItem>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.2.2</version>
<includes>com/sun/jna/linux-x86/*.so</includes>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FlattenFileMapper"/>
</fileMappers>
<outputDirectory>${project.build.directory}/extracted-libs/</outputDirectory>
</artifactItem>
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