开发者

maven-assembly-plugin causing tests to run twice

I have a maven project where I am using the assembly plugin. I typically create my artifacts by running: mvn clean verify assembly:assembly (I have integration tests which I want run separately to unit tests).

When this runs, the asse开发者_高级运维mbly plugin is running the unit tests itself. This causes them to be run twice.

Is there a way I can tell the assembly plugin not to run the tests? I am tempted to run this in two steps: 1. mvn clean verify 2. if previous command successful, run mvn assembly:assembly -DskipTests=true

However, this is a little clumsy and would rather the single command.

Thanks, Steven


When this runs, the assembly plugin is running the unit tests itself. This causes them to be run twice.

The assembly:assembly goal Invokes the execution of the lifecycle phase package prior to executing itself and running it on the command line will thus invoke any phase prior to package. And this includes the test phase.

Is there a way I can tell the assembly plugin not to run the tests?

No. My suggestion would be to create the assembly as part of the build lifecycle instead of invoking the plugin on the command line i.e. to bind it on a particular phase. For example:

<project>
 ...
 <build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <executions>
          <execution>
            <id>create-my-assembly</id>
            <phase>package</phase><!-- change this if not appropriate -->
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              ...
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

And if you don't want the assembly to be created if your integration tests fail, then bind it on a later phase (e.g. post-integration-test or verify).

And if you don't want the assembly to be systematically created, put the above configuration in a profile.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜