在“复制webapp资源"之后,如何调用ant任务来处理webapp文件.在“发动战争"之前打包阶段的步骤? [英] How to call ant task to process webapp files after "copying webapp resources" and before "building war" steps in package phase?

查看:117
本文介绍了在“复制webapp资源"之后,如何调用ant任务来处理webapp文件.在“发动战争"之前打包阶段的步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从蚂蚁迁移到行家.但是我有一个针对流程Web资源的自定义构建功能,我还不想适应Maven(成本很高),所以我正在使用ant run插件.

I'm migrating from ant to maven. However I have a custom build functionality for process web resources that I don't want to adapt yet to maven (the cost is very high) so I'm using ant run plugin.

我想处理一些调用ant任务的资源文件.这需要 在阶段包中的复制webapp资源"步骤之后和构建战争"步骤之前发生.

I want to process some of the resource files calling the ant task. This needs to happen after the "copying webapp resources" step and before the "building war" steps within the phase package.

当我运行我的ant任务时,阶段为包"

When I run my ant task, with the phase being "package"

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <ant antfile="${basedir}/build-resources.xml">
                                 <property name="runtime-classpath" refid="maven.runtime.classpath"/>
                            </ant>
                        </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>   

我可以完成对target/myapp-webapp文件夹下文件的mychanges.但是,由于 myapp-webapp.war是在运行ant任务之前构建的,这些更改不是 成为战争文件的一部分.

I can accomplish mychanges to the files under the target/myapp-webapp folder. However, since myapp-webapp.war is built before the ant task is run, these changes are not getting to be a part of that war file.

有没有办法做到这一点?

Is there a way to accomplish this?

推荐答案

看看

Have a look at the maven-lifecycle! If you bind your ant-task to the prepare-package phase or to the process-resources phase you should be able to accomplish your task.

如果您在执行中添加ID,则可以在控制台上更轻松地对其进行跟踪:

If you add an id to your execution you can follow it easier on the console:

...
<executions>
 <execution>
  <id>my-ant-processed-files</id>
  <phase>prepare-package</phase>
  ...

您正在处理哪些文件?

这篇关于在“复制webapp资源"之后,如何调用ant任务来处理webapp文件.在“发动战争"之前打包阶段的步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆