I have been trying to convert our Integration tests to use the Maven Exec Plugin to start a server but it will only start the HTTP Server after the Integration tests have been executed, even though I have pre-integration-test
specified.
Questions
Q1. Is there any other way to get the Integration tests to start after?
Q2. Is there a way to get the Integration phase to wait for the Server to start?
Q3. What's the difference between the Maven Exec and the Bazaar Maven Exec plugins?
Note: this worked previously using bazaar maven exec plugin but this is broken and can't seem to get it back working for JDK 11.0.9 on Jenkins.
The below is a snippet of our POM, we have various other plugins creating the jar and starting MockServer.
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>exec</id>
<phase>pre-integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<asyncDestroyOnShutdown>true</asyncDestroyOnShutdown>
<executable>java</executable>
<commandlineArgs>-Dserver.port=8089 -jar /gitRepos/public-api/target/api-jar-with-dependencies.jar</commandlineArgs>
<async>true</async>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<executions>
<execution>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<excludedGroups>${it.excluded}</excludedGroups>
<argLine>--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED</argLine>
<argLine>
--illegal-access=permit
</argLine>
</configuration>
</plugin>
</plugins>
<!-- this what was previously working. -->
<!-- <plugin>-->
<!-- <groupId>com.bazaarvoice.maven.plugins</groupId>-->
<!-- <artifactId>process-exec-maven-plugin</artifactId>-->
<!-- <version>0.9</version>-->
<!-- <configuration>-->
<!-- <processLogFile>${project.build.directory}/my-log.log</processLogFile>-->
<!-- </configuration>-->
<!-- </plugin>-->
The strange part for me is the HTTP Server starting after the Integration Tests, it's like other plugins are blocking the server from starting. See the logs below.
[DEBUG] Freed 4 thread-local buffer(s) from thread: nioEventLoopGroup-3-20
[DEBUG] Freed 4 thread-local buffer(s) from thread: nioEventLoopGroup-3-19
[DEBUG] Freed 5 thread-local buffer(s) from thread: nioEventLoopGroup-3-28
[INFO] [main] 13:13:37.594 [main] INFO c.i.p.s.Server - Grizzly ThreadPool for listener grizzly set to 24 worker threads.
[INFO] [main] 13:13:37.724 [main] INFO o.g.g.http.server.NetworkListener - Started listener bound to [0.0.0.0:8089]
[INFO] [main] 13:13:37.726 [main] INFO o.g.grizzly.http.server.HttpServer - [HttpServer] Started.