在maven中运行测试之前运行特定的插件

时间:2015-07-02 18:50:58

标签: maven

我有一个要求,我需要在运行单元测试或系统测试之前执行插件。有什么办法可以确保我的插件在mvn test之前执行

1 个答案:

答案 0 :(得分:0)

不确定。 Maven构建生命周期在phases中运行。您的插件可以配置为在特定阶段运行。

因此,您可以将其配置为在编译阶段或测试阶段运行(只需在测试阶段的maven-surefire-plugin之前声明它)

配置插件phase

的示例
  <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.5.5</version>
    <configuration>
      <descriptorRefs>
        <descriptorRef>jar-with-dependencies</descriptorRef>
      </descriptorRefs>
    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id> <!-- this is used for inheritance merges -->
        <phase>package</phase> <!-- bind to the packaging phase -->
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
  </plugin>