Thomas Sundberg

February 11, 2011

Maven and Antrun

Filed under: Maven, Teaching — Tags: , , — Thomas Sundberg @ 22:32

This post has been migrated to

A friend of mine needed an example of how to use the Antrun Maven plugin.

This is a simple example that will show how to execute any Ant targets from a Maven build during the install phase.

<?xml version="1.0" encoding="UTF-8"?>
                        <id>Hello World</id>
                                     Execute any Ant tasks here.
                                     Copy files if you need, echo hello world if
                                     you just want to show a working example.
                                <echo>Hello World</echo>

All we need to to is to set up the Antrun plugin in the build part of the pom.

To tie it to an execution phase, set the execution phase to the life cycle phase you want to execute your ant task in.
In this example I set it to the install phase.

If you want to execute more then one Ant task, then you have to set a unique id for each task.

That’s it folks!

Note that using Antrun is normally not The Maven Way ™
Investigate if you can use other options before you choose to use Antrun.


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

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

You are commenting using your 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

Blog at

%d bloggers like this: