maven可以运行命令行指令吗?

Max*_*Max 18 maven-2

我们可以将一些本机OS命令绑定到maven目标和/或阶段吗?

jit*_*ter 16

实际上有针对这些案例的Exec Maven插件.


小智 8

有关详细信息,请参阅exec-maven-plugin

  • 我想他可以从我提供的页面中找到该链接 (2认同)

Rom*_*las 5

不是原生的。

但是,通过使用AntRun 插件,您可以指定在构建期间执行操作系统命令的Ant 任务(使用Exec )。

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase> <!-- a lifecycle phase --> </phase>
            <configuration>
              <tasks>

                <!--
                  Place any Ant task here. You can add anything
                  you can add between <target> and </target> in a
                  build.xml.
                -->

              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>
Run Code Online (Sandbox Code Playgroud)