使用maven-dependency-plugin
以下文档有一个示例,其中他们将刚刚构建的工件复制到自定义位置。
https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html(在页面中搜索“依赖项:复制目标也可用于将刚刚构建的工件复制到如果需要,可以自定义位置”)
@Deadron 答案是正确的。我只是在这里复制正确的代码片段(有一些小的改进)以供更好的参考。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
</execution>
</executions>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
<overWrite>true</overWrite>
<outputDirectory>/my/install/path</outputDirectory>
<destFileName>MyDestJar.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</plugin>