开发者

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

开发者 https://www.devze.com 2023-03-05 03:12 出处:网络
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'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?


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消