user285879
user285879

Reputation:

How can I add a Maven exec task to execute on `mvn test`

I have the following exec task in my pom:

<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>

This works great when I run

mvn exec:exec

But I also want it to run when I execute

mvn test

Can anyone help me here?

Upvotes: 5

Views: 3741

Answers (1)

user285879
user285879

Reputation:

Got it! You add <phase> to the execution!

<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>

Woohoo!

Upvotes: 7

Related Questions