-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to override builder parameters
- Loading branch information
Showing
4 changed files
with
72 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/groovy/de/gesellix/gradle/docker/PortFinder.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package de.gesellix.gradle.docker | ||
|
||
class PortFinder { | ||
|
||
static int findFreePort() { | ||
ServerSocket socket = null | ||
try { | ||
socket = new ServerSocket(0) | ||
socket.setReuseAddress(true) | ||
int port = socket.getLocalPort() | ||
try { | ||
socket.close() | ||
} catch (IOException ignore) { | ||
// Ignore IOException on close() | ||
} | ||
return port | ||
} catch (IOException ignore) { | ||
} finally { | ||
if (socket != null) { | ||
try { | ||
socket.close() | ||
} catch (IOException ignore) { | ||
} | ||
} | ||
} | ||
throw new IllegalStateException("Could not find a free TCP/IP port") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters