views:

27

answers:

1

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

+2  A: 

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] ------------------------------------------------------------------------
...
Pascal Thivent
Oh man, what a ludicrously simple yet irritating bug! Thanks so much, you're like the Jon Skeet for Java :D
javamonkey79
@javamonkey79 You're welcome. Confusion between both plugins happens, it's the mismatch between the versions that got my attention.
Pascal Thivent