0

Here is the condensed snippet of pom.xml from my project

   <profiles>

            <profile>
                <id>run-tests</id>
                <build>
                    <plugins>
                        <plugin>
                            <groupId>com.google.code.maven-replacer-plugin</groupId>
                            <artifactId>replacer</artifactId>
                            <version>1.5.2</version>
                            <executions>
                                <execution>
                                    <phase>pre-integration-test</phase>
                                    <goals>
                                        <goal>replace</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <includes>
                                   ......
                                </includes>

                                <replacements>
                                    <replacement>
                                       .......
                                    </replacement>
                                </replacements>
                            </configuration>
                        </plugin>

                   <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-failsafe-plugin</artifactId>
                            <version>2.18.1</version>
                            <configuration>
                                ......
                            </configuration>
                            <executions>
                                <execution>
                                    <goals>
                                        <goal>integration-test</goal>
                                        <goal>verify</goal>
                                    </goals>
                                    <phase>integration-test</phase>
                                </execution>
                            </executions>
                        </plugin>
                     </plugins>
    </build>
</profile>
</profiles>

I have two questions:

1) when I execute mvn clean package -Prun-tests, what happens? I expected none of these plugin goals to execute here because they are bound to integration-test phase. But I see these goals executed why?

2) what does having two goals in execution block mean? please see above in failsafe-plugin

Thanks

brain storm
  • 30,124
  • 69
  • 225
  • 393

1 Answers1

1

A partial answer:

1) No Way. Unless you also have these plugins configured in the main build section to be run in phases up to package.

How did you determine that the plugins had run? Do you have something such as the following in the maven output?

[INFO] --- maven-failsafe-plugin:2.18.1:integration-test (default)

[INFO] --- maven-failsafe-plugin:2.18.1:verify (default)

2) That means that the two goals (mojos) will be executed in the integration-test phase. First the integration-test goal, immediately followed by the verify goal.

Comment: integration-test goal is by default bound to the integration-test phase, whereas the verify goal is bound to the verify phase. So you could have configured the failsafe plugin this way:

    <executions>
      <execution>
        <goals>
          <goal>integration-test</goal>
          <goal>verify</goal>
        </goals>
      </execution>
    </executions>

Note that the phase is ommited

Ori Dar
  • 18,687
  • 5
  • 58
  • 72
  • what does having `verify` goal without phase mean? – brain storm May 20 '15 at 07:03
  • for point 1 - do you mean the profile has no impact when run `mvn clean package -prun-tests`? – brain storm May 20 '15 at 07:04
  • verify goal without phase means that the verify goal runs in verify phase (to which it is bound by default) – Ori Dar May 20 '15 at 07:08
  • for point 1 - Yes, this is what I mean. The replacer plugin will be invoked if you run `mvn clean pre-integration-test -prun-tests` and onward, and the surefire plugin for `mvn clean integration-test -prun-tests` and onward – Ori Dar May 20 '15 at 07:12
  • by configuring failsafe plugin, the way you proposed, during `integration-test` phase, the goal `integration-test` but not `verify` will be executed. During `Verify` phase the goal `verify` but not `integration-test` will be executed. However, the way I had in my pom.xml above, it means during `integration-test` phase execute both `integration-test` and `verify` goals correct? – brain storm May 20 '15 at 16:28
  • Correct. The common practice is to execute integration-test goal in integration-test phase and the verify goal in verify phase (which in the next stage). Note that if you dont configure the verify goal (in any of those stages), the build passes even though you may have integration tests that fail – Ori Dar May 20 '15 at 17:29
  • why is that if I dont configure verify goal, the build will pass though integration test may fail? – brain storm May 20 '15 at 18:12