1
votes

I am still having problems how to configure jetty plugin in Maven to be able to start it run test using maven-surefire-plugin and then stop jetty server. So far it just run jetty and waits and it does not continue. Another issue is when the plugin should be jetty-maven-plugin or maven-jetty-plugin. I do not a difference between them. Anyway here an excerpt from my pom.xml.

<plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <!--version>9.2.11.v20150529</version-->
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <webApp>
                    <contextPath>/hellojavaworld</contextPath>           
                </webApp>    
                <war>c:\apache-tomcat-7.0.64\webapps\hellojavaworld.war</war>
                <stopPort>9966</stopPort>
                <stopKey>foo</stopKey>
            </configuration>

            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <!--configuration>
                        <daemon>true</daemon>
                    </configuration-->
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <excludes>
                    <exclude>*.java</exclude>
                </excludes>
            </configuration>
            <executions>
                <execution>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                        <excludes>
                            <exclude>none</exclude>
                        </excludes>
                        <includes>
                            <include>*.java</include>
                        </includes>
                    </configuration>
                </execution>
            </executions>
</plugin>

In the console is just:

[INFO] Started Jetty Server

[INFO] Starting scanner at interval of 10 seconds.

I want it to start jetty, run test (servlet container required), stop jetty and write BUILD SUCCESSFUL.

Does anybody have any suggestion? Thanks in advance.

2

2 Answers

1
votes

Problem was that tag <daemon></daemon> has to be specified. In my case was commented out. Another good source for jetty maven plugin is http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin

0
votes

I had the same problem when using version 9.2.2.v20140723 of the jetty plugin. After upgrading to 9.2.16.v20160414 maven continues with integration tests and stops the jetty server in the post-integration-test phase.