How to call ant task to process webapp files after “copying webapp resources” and before “building war” steps in package phase?

倾然丶 夕夏残阳落幕 提交于 2019-12-07 12:56:36

问题


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.

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.

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>   

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?


回答1:


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.

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>
  ...

What kind of processing are you doing to which files?



来源:https://stackoverflow.com/questions/5975465/how-to-call-ant-task-to-process-webapp-files-after-copying-webapp-resources-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!