Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.8.0
-
None
-
None
-
Windows 11, Java 21, Maven 3.8.6, Maven Dependency Plugin 3.8.0
Description
I was trying to use the unpack goal to unpack multiple artifacts with a similar structure (namely webjars) and rewrite their filenames using a common file mapper. The unpack goal conveniently defines the property fileMappers which seems suited for this use case. The configuration is as follows
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.8.0</version> <executions> <execution> <id>unpack-libraries</id> <phase>generate-resources</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.webjars.npm</groupId> <artifactId>chart.js</artifactId> <version>${chartjs.version}</version> </artifactItem> <artifactItem> <groupId>org.webjars.npm</groupId> <artifactId>chartjs-adapter-date-fns</artifactId> <version>3.0.0</version> </artifactItem> </artifactItems> <includes>META-INF/resources/webjars/*/*/dist/**</includes> <outputDirectory>${project.build.directory}/generated-resources/libraries</outputDirectory> <fileMappers> <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper> <pattern>^META-INF/resources/webjars/([^/]+)/[^/]+/dist/</pattern> <replacement>./$1/</replacement> </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper> </fileMappers> </configuration> </execution> </executions> </plugin>
This, however, does not work. While the artifacts are unpacked to the target directory, the globally configured fileMappers did not seem to take any effect.
After looking into the code of UnpackMojo it seems the UnpackMojo::getFileMappers method is unused. In UnpackMojo::getProcessedArtifactItems the includes and excludes of each artifact item are set to the globally configured values if empty, but the file mappers are left unchanged.