Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven, ant plugin, antrun:run

When executing 'mvn antrun:run' my tasks are not run.. I have an echo task, but no output is shown.. When running the phases that the tasks are bound to, they do get executed..

How do I specifically execute the tasks from the commandline?

like image 228
vpalle Avatar asked May 26 '09 11:05

vpalle


People also ask

What is Maven Antrun plugin?

This plugin provides the ability to run Ant tasks from within Maven. You can even embed your Ant scripts in the POM! It is not the intention of this plugin to provide a means of polluting the POM, so it's encouraged to move all your Ant tasks to a build.

Can we use Maven and Ant together?

As with any other Maven plugin, to make use of AntRun plugin, we need to define executions. Since we declared our plugin to run during Maven's package phase, running Maven's package goal will execute our plugin configuration above.

What is Maven clean plugin?

The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build. While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the target directory.


1 Answers

Assuming something like this is added to your pom.xml

<build>
   <plugins>
       <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
            <execution>
              <phase>package</phase><!--Change this to control when it runs -->
              <configuration>
                <tasks>
            <echo  message="Hello, maven"/>
                </tasks>
              </configuration>
              <goals>
                <goal>run</goal><!-- this is to call antrun:run -->
              </goals>
            </execution>
          </executions>
        </plugin>
     </plugins>
  </build>

Executing mvn package will result in the following on your console

[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] Hello, maven
[INFO] Executed tasks

You can change the phase to have your ant script run at whatever point you need.

like image 68
sal Avatar answered Sep 24 '22 02:09

sal