Maven的打包阶段完成后如何执行目标?
How to execute goal after completion of Maven's package phase?
我需要将打包的 jar 工件从 ${basedir}/target
复制到另一个子目录中。
但是当我尝试使用时 maven-resource-plugin I get broken jar with different size. I think it happens because package
phase is not completely finished when maven-resource-plugin 开始应对。
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-jar-after-package</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/dist</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target</directory>
<include>${artifactId}-${version}.jar</include>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
请删除 <filtering>true</filtering>
,否则 Maven 将像处理文本文件一样检查 jar,并尝试替换任何匹配的 ${*}
.
我需要将打包的 jar 工件从 ${basedir}/target
复制到另一个子目录中。
但是当我尝试使用时 maven-resource-plugin I get broken jar with different size. I think it happens because package
phase is not completely finished when maven-resource-plugin 开始应对。
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-jar-after-package</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/dist</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target</directory>
<include>${artifactId}-${version}.jar</include>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
请删除 <filtering>true</filtering>
,否则 Maven 将像处理文本文件一样检查 jar,并尝试替换任何匹配的 ${*}
.