maven,ant plugin,antrun:run

vpa*_*lle 8 ant maven-2 maven-plugin

执行'mvn antrun:run'时我的任务没有运行..我有一个echo任务,但没有显示输出..当运行任务绑定的阶段时,它们会被执行..

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

sal*_*sal 7

假设这样的东西被添加到你的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>
Run Code Online (Sandbox Code Playgroud)

执行mvn package将导致您的控制台上出现以下内容

[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
     [echo] Hello, maven
[INFO] Executed tasks
Run Code Online (Sandbox Code Playgroud)

您可以更改phase以在任何需要的位置运行您的ant脚本.