Use external IP address for open task

This commit is contained in:
Andrew Guibert 2018-10-19 12:04:27 -05:00
parent ab54fe6682
commit 5c0f8b8a40
5 changed files with 20 additions and 4 deletions

View File

@ -1,7 +1,7 @@
ext {
httpPort = 8082
httpsPort = 8482
appUrl = "http://localhost:${httpPort}/openapi/ui"
appUrl = "http://${hostname}:${httpPort}/openapi/ui"
}
liberty {

View File

@ -12,6 +12,22 @@ task clean(type: Delete) {
delete 'build'
}
ext.hostname = 'localhost'
// Find the public IP address for this machine (if one exists)
NetworkInterface.getNetworkInterfaces()
.findAll { it.isUp() && !it.isLoopback() && !it.isVirtual() }
.each {
it.getInetAddresses()
.findAll { !it.isLoopbackAddress() && it instanceof Inet4Address }
.each {
if (hostname.equals('localhost')) {
def hn = it.toString();
hostname = hn.startsWith("/") ? hn.substring(1, hn.length()) : hn;
// ${it} is in the format /<IP>, so only use http:/ instead of http://
}
}
}
subprojects {
apply plugin: 'liberty'
apply plugin: 'war'

View File

@ -19,7 +19,7 @@ ext {
httpPort = 12000
httpsPort = 12005
applicationName = "${war.archiveName}"
appUrl = "http://localhost:${httpPort}/"
appUrl = "http://${hostname}:${httpPort}/"
}
war {

View File

@ -6,7 +6,7 @@ dependencies {
ext {
httpPort = 8080
httpsPort = 8443
appUrl = "http://localhost:${httpPort}/openapi/ui"
appUrl = "http://${hostname}:${httpPort}/openapi/ui"
}
liberty {

View File

@ -1,7 +1,7 @@
ext {
httpPort = 8081
httpsPort = 8444
appUrl = "http://localhost:${httpPort}/openapi/ui"
appUrl = "http://${hostname}:${httpPort}/openapi/ui"
}
liberty {