Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Dashboard
Maven User
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h2>Passing your Maven classpath to Ant:</h2> <p>In your pom.xml, configure something like this:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>build-config-files</id> <phase>compile</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <property name="runtime-classpath" refid="maven.runtime.classpath"/> <ant target="build" inheritRefs="true"/> </tasks> </configuration> </execution> </executions> </plugin> </plugins> </build> </pre></td></tr></table> <p>In your build.xml, have something like:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <path id="project.class.path"> <path path="${runtime-classpath}"/> </path> </pre></td></tr></table> <p>The path that maven is using should now be assigned to "runtime-classpath".</p> <p>This is very useful for calling a custom ant task, when the definition is in your maven classpath. <br class="atl-forced-newline" /></p> <h2>Using ant-contrib tasks:</h2> <p>To use ant-contrib tasks with the maven-antrun-plugin you'll need to do a couple of things:</p> <p>1. Add a taskdef.</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/> </pre></td></tr></table> <p>2. Add some dependencies for the plugin:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <dependencies> <dependency> <groupId>ant-contrib</groupId> <artifactId>ant-contrib</artifactId> <version>1.0b3</version> <exclusions> <exclusion> <groupId>ant</groupId> <artifactId>ant</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>ant</groupId> <artifactId>ant-nodeps</artifactId> <version>1.6.5</version> </dependency> </dependencies> </pre></td></tr></table> <p>Notice that the transcient dependency on ant:ant is execluded for ant-contrib. This is due to ant-contrib having a dependency on ant-1.5. I was getting the following error before replacing ant with ant-nodeps-1.6.5:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> Error configuring: org.apache.maven.plugins:maven-antrun-plugin. Reason: java.lang.NoSuchMethodError: org.apache.tools.ant.util.FileUtils.close(Ljava/io/InputStream;) </pre></td></tr></table> <p>Here's full example of using the antrun plugin to move a war file to a jboss server deploy directory once it is built. You can also define the <em>unpacked</em> property (ie. mvn install -Dunpacked) to have the app moved exploded (or unpacked).</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <phase>install</phase> <configuration> <tasks> <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath"/> <delete file="${my.jboss.server}/deploy/${build.finalName}.war"/> <delete dir="${my.jboss.server}/deploy/${build.finalName}.war"/> <if> <isset property="unpacked"/> <then> <mkdir dir="${my.jboss.server}/deploy/${build.finalName}.war"/> <unzip src="${project.build.directory}/${build.finalName}.war" dest="${wsm.jboss.server}/deploy/${build.finalName}.war"/> </then> <else> <copy todir="${my.jboss.server}/deploy"> <fileset dir="${project.build.directory}" includes="${build.finalName}.war"/> </copy> </else> </if> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> <dependencies> <dependency> <groupId>ant-contrib</groupId> <artifactId>ant-contrib</artifactId> <version>1.0b3</version> <exclusions> <exclusion> <groupId>ant</groupId> <artifactId>ant</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>ant</groupId> <artifactId>ant-nodeps</artifactId> <version>1.6.5</version> </dependency> </dependencies> </plugin> </pre></td></tr></table> <h2>Maven plugin classpath bug.</h2> <p>Using the Maven Antrun Plugin in multiple projects in the Reactor</p> <p>In Maven 2.x, there is a significant bug that can lead to very perplexing failures with the antrun plugin. There are two conditions that you have to meet to get into this problem.</p> <p>1) You have to use the plugin in two projects that are loaded into the reactor via <modules/> .<br /> 2) You have to require additional plugin dependencies on the plugin.</p> <p>In Maven 2.x, the dependencies of the first project into the reactor win, and all the others are entirely ignored.</p> <p>Concretely, if your first project uses the plugin with no special dependencies, and your second one tries to use ant-trax, the second antrun execution will fail, and complain that it can't find the classes in ant-trax.</p> <p>The only solution to this is to ensure that, in all of the places where you use the plugin, you list the same dependencies.</p> <p>This problem has been fixed in Maven 3.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced