yegor256
yegor256

Reputation: 105043

How to get port number from jetty-maven-plugin?

jetty-maven-plugin 7.x, when used in integration testing, dynamically finds available port, in runtime. How can I save the number of the port found and use it in Java integration tests? Maybe jetty-maven-plugin can save it into a system variable?

Upvotes: 3

Views: 2458

Answers (1)

yegor256
yegor256

Reputation: 105043

This is how it works:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.6</version>
            <configuration>
                <portNames>
                    <portName>jetty.port</portName>
                    <portName>jetty.port.stop</portName>
                </portNames>
            </configuration>
            <executions>
                <execution>
                    <id>reserve-port</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>reserve-network-port</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Then ${jetty.port} can be used for jetty plugin.

Upvotes: 4

Related Questions