I'm trying to run some Selenium tests but it is not working to attach the starting of jetty to the pre-integration-test phase of maven. So I tried to investigate the problem and it seems that in general Maven is not executing my goals in the phases I specified.
I found this example and reproduced it. I created the plugin which works fine when I call it explicitly. But when I try to attach it to the validate phase and run mvn validate I don't see the "Hi there!!!" output. It simply shows me build success without calling the howdy-world goal :/ (which is consistent with my jetty not starting in integration-test phase)
How can I make this goal run when the validation phase is passed?
Here's my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.maventest</groupId>
<artifactId>aproject</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>aproject</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.maventest</groupId>
<artifactId>maven-howdy-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>howdy-world</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
You have to do it that way:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<pluginManagement>
<plugins>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>com.maventest</groupId>
<artifactId>maven-howdy-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>howdy-world</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>com.maventest</groupId>
<artifactId>maven-howdy-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</plugin>
</plugins>
</pluginManagement>
<!-- The following will really execute the plugin -->
<plugins>
<plugin>
<groupId>com.maventest</groupId>
<artifactId>maven-howdy-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>howdy-world</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The pluginManagement
part is only intended to define versions and configuration for plugins but it will not really execute those plugins within the life-cycle.