Maven-antrun No ant target defined - SKIPPED
Asked Answered
D

3

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"?

Decedent answered 25/9, 2013 at 9:43 Comment(0)
G
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

Grijalva answered 2/10, 2015 at 14:49 Comment(2)
Even when this make sense, doesn't work for me, this post gave me the answer: stackoverflow.com/a/11009854. p.s.: I didn't see the next post.Malmo
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.Falconet
H
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.

Hogshead answered 28/9, 2013 at 9:5 Comment(1)
thx i don't want it to run on regular build lifecycle. i want it to run only on demand.Decedent
I
6

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

Icelander answered 18/5, 2015 at 9:8 Comment(2)
Can you please add more explanation to your answer?Fleda
When you have more then one execution in a plugin, you can execute the execution you want by issuing maven command in this rule: mvn <plugin_name>:<goal>@<execution_id>Icelander

© 2022 - 2024 — McMap. All rights reserved.