【问题标题】:How can I add a Maven exec task to execute on `mvn test`如何添加 Maven exec 任务以在“mvn test”上执行
【发布时间】:2011-01-27 20:50:04
【问题描述】:

我的 pom 中有以下 exec 任务:

<plugins>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.1</version>
    <executions>
      <execution>
        <goals>
          <goal>exec</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <executable>${project.basedir}/src/test/javascript/EnvJasmine/bin/run_all_tests.sh</executable>
    </configuration>
  </plugin>
</plugins>

这在我运行时效果很好

mvn exec:exec

但我也希望它在执行时运行

mvn test

有人可以帮我吗?

【问题讨论】:

    标签: java testing maven exec


    【解决方案1】:

    知道了!您将&lt;phase&gt; 添加到执行中!

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
          <execution>
            <id>Jasmine Tests</id>
            <phase>test</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>${project.basedir}/src/test/javascript/EnvJasmine/bin/run_all_tests.sh</executable>
        </configuration>
      </plugin>
    </plugins>
    

    哇哦!

    【讨论】:

    • 具体来说,要在test 阶段执行,您需要将&lt;phase&gt;test&lt;/phase&gt; 绑定项添加到&lt;execution&gt; 元素中。
    • 嗨,刚刚进入你的帖子。我已经制定了 exec maven 插件来运行外部命令。此命令为集成测试运行服务器。我的问题是 maven 卡在这个命令上,所以我从来没有运行过测试。我想知道你们中的一些人是否已经弄清楚了。
    猜你喜欢
    • 2014-07-04
    • 1970-01-01
    • 1970-01-01
    • 2020-03-16
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-22
    相关资源
    最近更新 更多