14

i am trying to copy a file in my maven multi-module project via antrun plugin. the file is in root of parent project:

<plugin>                                                           
<groupId>org.apache.maven.plugins</groupId>                    
<artifactId>maven-antrun-plugin</artifactId>                   
<version>1.7</version>                                         
<inherited>false</inherited>                                   
<executions>                                                   
    <execution>                                                
        <inherited>false</inherited>                           
        <id>copy</id>                                          
        <goals>                                                
            <goal>run</goal>                                   
        </goals>                                               
        <configuration>                                        
            <target name="copy and rename file">               
                <copy file="${basedir}/portal-ext.properties" tofile="${liferay.auto.deploy.dir}/../portal-ext.properties" />

            </target>                                          
        </configuration>                                       
    </execution>                                               
</executions>                                                  

i run this via mvn antrun:run the problem is i get "No ant target defined - SKIPPED" on parent and on every module. i need it to run only on parent and thought <inherited>false</inherited> would help but i doesn't. But why "No ant target defined"?

dermoritz
  • 12,519
  • 25
  • 97
  • 185

3 Answers3

23
  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
      <execution>
        <id>ant-execute</id>
        <configuration>
          <target>
          <echo message="plugin classpath:  " />
          </target>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

command : mvn antrun:run@ant-execute

venkat
  • 246
  • 2
  • 2
  • 1
    Even when this make sense, doesn't work for me, this post gave me the answer: http://stackoverflow.com/a/11009854. p.s.: I didn't see the next post. – Vielinko Mar 08 '16 at 22:39
  • I'll add this comment here, too, in the hope it may help someone trying to figure out why this command does not work: if you use `mvn antrun:run@myexecutionid` and your antrun-target is in a plugin, which resides inside a profile, you **absolutely do need to include the name of the profile in the command line**. E.g.: `mvn -P myprofile antrun:run@myexecutionid`. – Igor Aug 29 '19 at 16:34
6

antrun:run will only consider the plugin's configuration, not that for a specific execution, so the execution you specify is ignored. As Run a single Maven plugin execution? states, you can give your execution an id of default-cli to have it picked up.

However, the execution you configure should already be taking effect during the regular build lifecycle.

Community
  • 1
  • 1
Joe
  • 29,416
  • 12
  • 68
  • 88
6

just run it like this: mvn antrun:run@copy

Jesse Hwong
  • 61
  • 1
  • 3