@Mojo(name="reserve-network-port",
defaultPhase=PROCESS_TEST_CLASSES,
threadSafe=true)
public class ReserveListenerPortMojo
extends org.apache.maven.plugin.AbstractMojo
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
BUILD_HELPER_RESERVED_PORTS |
private static java.lang.Integer |
FIRST_NON_ROOT_PORT_NUMBER |
private static java.lang.Object |
lock |
private static java.lang.Integer |
MAX_PORT_NUMBER |
private java.lang.Integer |
maxPortNumber
Specify this if you want the port be chosen with a number lower than that one.
|
private java.lang.Integer |
minPortNumber
Specify this if you want the port be chosen with a number higher than that one.
|
private java.io.File |
outputFile
Output file to write the generated properties to.
|
private java.lang.String[] |
portNames
A List to property names to be placed in Maven project
|
private org.apache.maven.project.MavenProject |
project |
Constructor and Description |
---|
ReserveListenerPortMojo() |
Modifier and Type | Method and Description |
---|---|
void |
execute() |
private int |
findAvailablePortNumber(java.lang.Integer portNumberStartingPoint,
java.util.List<java.lang.Integer> reservedPorts)
Returns the first number available, starting at portNumberStartingPoint that's not already in the reservedPorts
list.
|
private int |
getNextPortNumber() |
private java.util.List<java.lang.Integer> |
getReservedPorts() |
private java.net.ServerSocket |
getServerSocket() |
private static final java.lang.String BUILD_HELPER_RESERVED_PORTS
private static final java.lang.Integer FIRST_NON_ROOT_PORT_NUMBER
private static final java.lang.Integer MAX_PORT_NUMBER
private static final java.lang.Object lock
@Parameter(required=true) private java.lang.String[] portNames
@Parameter private java.io.File outputFile
@Parameter private java.lang.Integer minPortNumber
If maxPortNumber
is specified, defaults to .
@Parameter private java.lang.Integer maxPortNumber
@Component private org.apache.maven.project.MavenProject project
public void execute() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private java.net.ServerSocket getServerSocket() throws java.io.IOException, org.apache.maven.plugin.MojoExecutionException
java.io.IOException
org.apache.maven.plugin.MojoExecutionException
private int getNextPortNumber()
private java.util.List<java.lang.Integer> getReservedPorts()
private int findAvailablePortNumber(java.lang.Integer portNumberStartingPoint, java.util.List<java.lang.Integer> reservedPorts)
portNumberStartingPoint
- first port number to start from.reservedPorts
- the ports already reserved.