【问题标题】:Maven-antrun No ant target defined - SKIPPEDMaven-antrun 未定义 ant 目标 - 已跳过
【发布时间】:2013-09-25 09:43:16
【问题描述】:

我正在尝试通过 antrun 插件在我的 maven 多模块项目中复制一个文件。该文件位于父项目的根目录中:

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

我通过mvn antrun:run 运行它,问题是我在父模块和每个模块上都得到“没有定义蚂蚁目标 - 跳过”。我需要它只在父级上运行,并认为&lt;inherited&gt;false&lt;/inherited&gt; 会有所帮助,但我没有。但是为什么“没有定义蚂蚁目标”呢?

【问题讨论】:

    标签: maven maven-antrun-plugin


    【解决方案1】:
      <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>
    

    命令 : mvn antrun:run@ant-execute

    【讨论】:

    • 即使这很有意义,但对我不起作用,这篇文章给了我答案:stackoverflow.com/a/11009854。 p.s.:我没看到下一个帖子。
    • 我也会在此处添加此评论,希望它可以帮助试图弄清楚为什么此命令不起作用的人:如果您使用 mvn antrun:run@myexecutionid 并且您的 antrun-target 位于插件,驻留在配置文件中,您绝对需要在命令行中包含配置文件的名称。例如:mvn -P myprofile antrun:run@myexecutionid.
    【解决方案2】:

    antrun:run 只会考虑插件的配置,不会考虑特定的执行,所以你指定的执行会被忽略。正如Run a single Maven plugin execution? 所述,您可以为您的执行提供一个default-cli 的ID 以使其被拾取。

    但是,您配置的执行应该已经在常规构建生命周期中生效。

    【讨论】:

    • thx 我不希望它在常规构建生命周期中运行。我希望它只按需运行。
    【解决方案3】:

    像这样运行它:mvn antrun:run@copy

    【讨论】:

    • 您能否为您的答案添加更多解释?
    • 当插件中有多个执行时,您可以通过在此规则中发出maven命令来执行您想要的执行:mvn &lt;plugin_name&gt;:&lt;goal&gt;@&lt;execution_id&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-06
    • 2012-05-11
    • 1970-01-01
    • 2019-09-06
    相关资源
    最近更新 更多