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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With