【问题标题】:How to execute multiple cmd commands using maven?如何使用maven执行多个cmd命令?
【发布时间】:2014-03-30 18:55:56
【问题描述】:

我想在 maven 中使用单个 pom.xml. 运行多个 CMD 命令

我可以知道我该怎么做吗?

例如

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <id>id1</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>cmd1</executable>
            </configuration>
        </execution>
        <execution>
            <id>id2</id>
            <phase>install</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>cmd2</executable>
            </configuration>
        </execution>
    </executions> </plugin>

【问题讨论】:

  • 那么问题出在哪里?它有效还是无效?除此之外,为什么您需要在构建中执行特定于操作系统的东西?某种测试?如果是,install 阶段看起来是错误的。
  • 不,它只是一个例子。我想在构建项目时运行 grunt 命令。
  • 我不确定,但这可能是更好的解决方案:github.com/allegro/grunt-maven-plugin

标签: java maven build pom.xml


【解决方案1】:

您可以为 cmd1 和 cmd2 引入两个不同的profiles

【讨论】:

  • 不,它不是这样,它只是一个例子。我想使用 cmd 运行 grunt 命令
【解决方案2】:

也许exec-maven-plugin:

运行将按顺序运行您的 cmds 的脚本::

        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>exec-maven-plugin</artifactId>
          <version>1.2</version>
          <executions>
            <execution>
              <id>run a backup</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>exec</goal>
              </goals>
              <configuration>
                <executable>/path/to/backup-script/bkp.sh</executable>
              </configuration>
            </execution>
          </executions>
        </plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-09
    • 2021-02-19
    相关资源
    最近更新 更多