当我构建项目时,我运行此命令:
mvn clean package
我希望在package
阶段内将默认目标目录中生成的jar文件复制到另一个目录中。
我怎么能用Maven做到这一点?
答案 0 :(得分:1)
您可以使用ant run插件复制内容。
以下摘自pom
中的rhq-project.org <build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>deploy-jar-meta-inf</id>
<phase>package</phase>
<configuration>
<tasks>
<unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${rhq.deploymentDir}" overwrite="false">
<patternset>
<include name="META-INF/**" />
</patternset>
</unjar>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>undeploy</id>
<phase>clean</phase>
<configuration>
<tasks>
<property name="deployment.dir" location="${rhq.deploymentDir}" />
<echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
<delete dir="${deployment.dir}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
答案 1 :(得分:1)
默认情况下,在POM中继承的超级POM中声明的文件夹。
<build>
<directory>${project.basedir}/target</directory>
</build>
您可以通过下一个方式在pom.xml中更改它:
<build>
<directory>${project.basedir}/yourFolder</directory>
</build>