maven antrun plugin
Asked Answered
P

2

19

I have the following in my pom:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ant-plugin</artifactId>
    <version>2.3</version>
    <configuration>
       <target>
          <echo
            message="hello ant, from Maven!" />
          <echo>Maybe this will work?</echo>
       </target>
    </configuration>
</plugin>

Yet, when I run 'mvn antrun:run' I get this:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'antrun'.
[INFO] ------------------------------------------------------------------------
[INFO] Building myProject
[INFO]    task-segment: [antrun:run]
[INFO] ------------------------------------------------------------------------
[INFO] [antrun:run {execution: default-cli}]
[INFO] Executing tasks
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Sep 24 13:33:14 PDT 2010
[INFO] Final Memory: 16M/28M
[INFO] ------------------------------------------------------------------------

How come the echo's don't show up?

TIA

Pericarp answered 24/9, 2010 at 20:37 Comment(1)
To reiterate something I missed - make sure and use version 1.5+ of the plugin.Pericarp
G
29

Because you are supposed to use the Maven AntRun Plugin if you want to execute Ant tasks, not the Maven Ant Plugin (which is used to generate build files for Ant 1.6.2 or above from the POM). Modify your plugin configuration as below:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.5</version>
    <configuration>
      <target>
        <echo message="hello ant, from Maven!"/>
        <echo>Maybe this will work?</echo>
      </target>
    </configuration>
  </plugin>

And invoking antrun:run will work:

$ mvn antrun:run 
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Q3790798 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-antrun-plugin:1.5:run (default-cli) @ Q3790798 ---
[INFO] Executing tasks

main:
     [echo] hello ant, from Maven!
     [echo] Maybe this will work?
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
...
Grizzle answered 24/9, 2010 at 20:59 Comment(2)
Oh man, what a ludicrously simple yet irritating bug! Thanks so much, you're like the Jon Skeet for Java :DPericarp
@Pericarp You're welcome. Confusion between both plugins happens, it's the mismatch between the versions that got my attention.Grizzle
S
3

Make sure maven-antrun-plugin is using a recent enough version.

An unrelated BOM in my project was locking it to 1.3, and <echo> was being ignored. After removing the BOM and specifying 1.7 for antrun, the echoes worked.

Spoonful answered 11/9, 2013 at 7:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.