Maven – Using Ant tasks with maven-antrun-plugin

maven-antrun-plugin allows maven user to add ant tasks in different maven life cycle phases. To use the maven-antrun-plugin, add the following text in the pom.xml.

<!-- Build Configuration -->
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.7</version>
      <executions>
        <execution>
          <id>initialize</id>
          <phase>initialize</phase>
          <configuration>
            <tasks>
              <echo>Hello Maven</echo>
            </tasks>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

This is the output after running mvn initialize

...
[INFO] task-segment: [initialize]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run]
[INFO] Executing tasks
     [echo] Hello Maven
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Dec 16 18:04:57 CST 2009
[INFO] Final Memory: 2M/7M
[INFO] ------------------------------------------------------------------------

 

Done =)

Advertisements

3 thoughts on “Maven – Using Ant tasks with maven-antrun-plugin”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s