How to call ant task to process webapp files after

2019-05-10 22:33发布

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条回答
疯言疯语
2楼-- · 2019-05-10 23:00

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?

查看更多
登录 后发表回答