如何在`mvn test`上添加Maven exec任务来执行

3 java testing exec maven

我的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>
Run Code Online (Sandbox Code Playgroud)

我跑的时候效果很好

mvn exec:exec
Run Code Online (Sandbox Code Playgroud)

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

mvn test
Run Code Online (Sandbox Code Playgroud)

有人能帮我一下吗?

小智 5

得到它了!你加入<phase>执行!

<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>
Run Code Online (Sandbox Code Playgroud)

哇噢!