Maven 将 Target 中生成的 JAR 复制到外部文件夹
Maven copy JAR generated in Target to external folder
在常规的 Netbeans 项目中,您有一个 build.xml,我可以使用以下方法将生成的 JAR 文件复制到不同的文件夹:
<target name ="-post-jar" >
<copy file ="${dist.jar}" todir ="../Plugin Jars" failonerror ="true"/>
<copy file ="${dist.jar}" todir ="/Users/dev/Desktop/plugins" failonerror ="true"/>
</target>
现在我有一个使用 Maven 的项目,但我找不到完成相同任务的方法。
编辑:感谢我们的贡献者,我能够通过以下条目做到这一点
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
</artifactItem>
</artifactItems>
<outputDirectory>/Users/dev/Desktop/plugins</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
使用 maven-dependency-plugin
以下文档有一个示例,其中他们将刚刚构建的工件复制到自定义位置。
https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html(在页面中搜索 "The dependency:copy goal can also be used to copy the just built artifact to a custom location if desired")
在常规的 Netbeans 项目中,您有一个 build.xml,我可以使用以下方法将生成的 JAR 文件复制到不同的文件夹:
<target name ="-post-jar" >
<copy file ="${dist.jar}" todir ="../Plugin Jars" failonerror ="true"/>
<copy file ="${dist.jar}" todir ="/Users/dev/Desktop/plugins" failonerror ="true"/>
</target>
现在我有一个使用 Maven 的项目,但我找不到完成相同任务的方法。
编辑:感谢我们的贡献者,我能够通过以下条目做到这一点
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-installed</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>${project.packaging}</type>
</artifactItem>
</artifactItems>
<outputDirectory>/Users/dev/Desktop/plugins</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
使用 maven-dependency-plugin
以下文档有一个示例,其中他们将刚刚构建的工件复制到自定义位置。
https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-artifacts.html(在页面中搜索 "The dependency:copy goal can also be used to copy the just built artifact to a custom location if desired")