Maven 在其他一切完成后重命名文件 [英] Maven rename a file after everything else finishes
问题描述
我有一个项目,我需要在其他一切完成后(在编译/构建/组装过程中)重命名由 Maven Assembly Plugin
生成的最终输出文件.
I have a project which I need to rename the final output file generated by the Maven Assembly Plugin
after everything else finishes (in the compiling/building/assembly process).
Maven Assembly Plugin
正在根据项目名称生成最终的 final-version.牛
.我正在尝试使用 maven-antrun-plugin
来重命名它,正如这里其他类似问题所指出的那样,但没有运气(我以前从未使用过 Maven 或 Ant,所以也许我是遗漏了什么).
The Maven Assembly Plugin
is generating a final .zip
file, based on the project's name, and I need to rename this completely to final-version.oxt
. I'm trying to use the maven-antrun-plugin
to rename it, as pointed by other similar questions here, but no luck (I've never used Maven or Ant before, so maybe I'm missing something).
这是项目pom.xml
的
部分.重命名部分似乎被完全忽略了,因为我的 home
文件夹中没有生成文件.
This is the <build>
section of the project's pom.xml
. The rename part seems to be completely ignored, since no file is generated in my home
folder.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
<descriptors>
<descriptor>src/main/assembly/ooo-jar.xml</descriptor>
<descriptor>src/main/assembly/ooo.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>deploy</phase>
<configuration>
<tasks>
<copy file="${project.build.directory}/target/libreofficeplugin-ooo.zip"
tofile="/home/brunofinger/final-version.oxt" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
推荐答案
一些修改使它工作,可能 phase
是错误的,但使用
似乎使它工作:
A few modifications made it work, probably the phase
was wrong, but using <phase>install</phase>
seems to make it work:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<copy file="${project.build.directory}/libreofficeplugin-ooo.zip" tofile="${project.build.directory}/final-version.oxt" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
这篇关于Maven 在其他一切完成后重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!