如何使用 Maven 依赖插件更改位置?
How to change location with Maven Dependency Plugin?
我需要将一些资源从工件复制到特定位置。
我需要在不展平的情况下更改位置。
例如:
my-res-artifact
\
someroot/subdir1/
+ myres1.dat
+ myres2.dat
\
subdir12
+ myres3.dat
我想将其复制到 subdir1
目录,但删除 someroot
根目录。这不适用于以下内容:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-additional-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.example</includeGroupIds>
<includeArtifactIds>my-res-artifact</includeArtifactIds>
<includes>someroot/subdir1/**</includes>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
目录结构 someroot/subdir1/
被保留。
可以通过文件映射器更改文件名。
这个技巧也适用于整个位置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-additional-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.example</includeGroupIds>
<includeArtifactIds>my-res-artifact</includeArtifactIds>
<includes>someroot/subdir1/**</includes>
<outputDirectory>${project.build.directory}</outputDirectory>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.RegExpFileMapper">
<pattern>someroot/subdir1</pattern>
<replacement>subdir1</replacement>
</fileMapper>
</fileMappers>
</configuration>
</execution>
</executions>
</plugin>
我需要将一些资源从工件复制到特定位置。 我需要在不展平的情况下更改位置。
例如:
my-res-artifact
\
someroot/subdir1/
+ myres1.dat
+ myres2.dat
\
subdir12
+ myres3.dat
我想将其复制到 subdir1
目录,但删除 someroot
根目录。这不适用于以下内容:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-additional-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.example</includeGroupIds>
<includeArtifactIds>my-res-artifact</includeArtifactIds>
<includes>someroot/subdir1/**</includes>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
目录结构 someroot/subdir1/
被保留。
可以通过文件映射器更改文件名。
这个技巧也适用于整个位置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-additional-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.example</includeGroupIds>
<includeArtifactIds>my-res-artifact</includeArtifactIds>
<includes>someroot/subdir1/**</includes>
<outputDirectory>${project.build.directory}</outputDirectory>
<fileMappers>
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.RegExpFileMapper">
<pattern>someroot/subdir1</pattern>
<replacement>subdir1</replacement>
</fileMapper>
</fileMappers>
</configuration>
</execution>
</executions>
</plugin>