开发者

Running antrun during war:exploded

For a Maven build I need to copy some files after the exploded directory has been made with the war plugin. Is it possible to run the antrun plugin during/after the war:exploded goal? If so how would I do this? I've tried:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
        <execution>
          <phase>war</phase>
          <goals>
            <goal>exploded</goal>
          </goals>
          <configuration>
            <tasks>
              <echo>Running ant task...</echo>
            </tasks>
          </configuration>
        </execution>
      </executions>
    &l开发者_如何转开发t;/plugin>
  </plugins>
</build>

And several other variation but can't seem to get it to run.

Idealy I'd like the ant task to run if I do a full war:war too but I'll cross this bridge when I come to it.


There are at least two ways to achieve it:

Using direct invocation of plugins

When calling mvn war:exploded oder mvn war:war, you only call a specific goal of a specific plugin. No other plugin is executed. Executions defined in pom.xml are not relevant. As a consequence, you could only call several plugin goals directly, for example mvn war:exploded antrun:run.

But be careful when building several modules: mvn war:exploded antrun:run runs antrun after the war plugin for each module. Whereas mvn war:exploded; mvn antrun:run runs the war plugin for all modules and then antrun for all modules.

Using lifecycle bindings of plugins

When calling mvn pre-integration-test, you call all phases of the default lifecycle up to pre-integration-test. You could define an war plugin execution for goal "exploded" in phase "package" and an antrun execution for goal "run" in phase "pre-integration-test".


There is no phase "war" in the default lifecycle. So your example above won't work with the default lifecycle. And for a custom lifecycle with custom phases, you need custom plugins.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜