Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-failsafe-plugin won't run on verify and does not find xml on failsafe:verify

The Maven failsafe plugin will not run on my project. If I run mvn verify only surefire runs. If I type mvn failsafe:verify it fails with the following error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-failsafe-plugin:2.11:verify (default-cli) on project experiment-server: /home/user/workspace/MyProject-Main/MyProject-IntegrationTest/target/failsafe-summary.xml (The system cannot find the path specified) -> [Help 1]

So I basicly have the same problem as: failsafe plugin won't run on one project but will run on another -- why? With the difference that my pom already looks like this:

<plugin>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.14.1</version>
    <executions>
        <execution>
            <id>failsafe-integration-tests</id>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
        </execution>
        <execution>
            <id>failsafe-verify</id>
            <phase>verify</phase>
            <goals>
                <goal>verify</goal>
            </goals>
        </execution>
    </executions>
</plugin>

And this was the solution to this guys problem. Except the solutions on this site didn't work for me. Can someone point out where I messed up?

I also have the problem that I want to start a server with exec-maven-plugin in pre-integration-phase. But when I try mvn-verify it's the very last thing that gets executed.

like image 761
user2368505 Avatar asked Mar 24 '23 22:03

user2368505


2 Answers

Just found out for this one, solution is here: http://maven.apache.org/surefire/maven-failsafe-plugin/plugin-info.html

maven-failsafe-plugin, contrarely to maven-compiler-plugin for example, is NOT in the default maven build lifecycle.

Consequently, one must respect this tags hierarchy:

<project>
  <build>
    <pluginManagement>
      <plugins>
        <!-- For understanding only, below is the 'maven-compiler-plugin':
             its path is 'project -> build -> pluginManagement -> plugins
             -> plugin', because it's defaulty part of the maven build
             lifecycle: we just 'manage' it -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          ..
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <!-- HERE is the 'maven-failsafe-plugin':
           its path is 'project -> build -> plugins ->
           plugin', because it's NOT defaulty part of
           the maven build lifecycle: we have to
           'define' it, and not just manage it as
           stated earlier -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        ..
      </plugin>
    </plugins>
  </build>
<project>

Quoting from the official documentation link: "To define the plugin version in your parent POM" and "To use the plugin goals in your POM or parent POM". One must pay attention to the difference.

like image 116
Pascal Avatar answered Mar 26 '23 13:03

Pascal


I moved my failsafe pom snippet to the parents pom and that seems to do the trick. I have no Idea why.

like image 30
user2368505 Avatar answered Mar 26 '23 12:03

user2368505