【问题标题】:maven, ant plugin, antrun:runmaven, ant 插件, antrun:run
【发布时间】:2009-05-26 11:18:39
【问题描述】:

执行“mvn antrun:run”时,我的任务没有运行。我有一个回显任务,但没有显示输出。运行任务绑定的阶段时,它们确实被执行了。。

如何从命令行专门执行任务?

【问题讨论】:

    标签: maven-2 ant maven-plugin


    【解决方案1】:

    假设这样的东西被添加到你的 pom.xml

    <build>
       <plugins>
           <plugin>
              <artifactId>maven-antrun-plugin</artifactId>
              <executions>
                <execution>
                  <phase>package</phase><!--Change this to control when it runs -->
                  <configuration>
                    <tasks>
                <echo  message="Hello, maven"/>
                    </tasks>
                  </configuration>
                  <goals>
                    <goal>run</goal><!-- this is to call antrun:run -->
                  </goals>
                </execution>
              </executions>
            </plugin>
         </plugins>
      </build>
    

    执行mvn package 将在您的控制台上产生以下结果

    [INFO] [antrun:run {execution: default}]
    [INFO] Executing tasks
         [echo] Hello, maven
    [INFO] Executed tasks
    

    您可以更改 phase 以让您的 ant 脚本在您需要的任何时候运行。

    【讨论】:

    • 感谢您的回答。我正在使用这个特定的 ant 任务来部署一个轴 web 服务(使用一个名为 AdminClient 的程序)。我只能在我的容器(在本例中为 jetty:run )启动后部署它。那么哪个阶段是相关的?
    • Jetty:run 可能会在预集成测试中运行。我会将阶段更改为集成测试后。运行“mvn verify”来运行 jetty 和 ant 任务。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-17
    • 2018-12-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-22
    • 2011-02-03
    相关资源
    最近更新 更多