browser로 URL 열기
Less than 1 minute
browser로 URL 열기 관련
Gradle > Snippets
Snippets
웹브라우저로 페이지를 열기 위한 task
./
./<모듈>/
build.gradle
Groovy
task openBrowser {
description = "open browser to the running application"
doLast {
String port = 8080
String contextName = "contextName"
String URL = "http://localhost:" + port + "/" + contextName + "/"
java.awt.Desktop.desktop.browse URL.toURI()
}
}
Kotlin
import java.awt.Desktop
import java.net.URL
// ... 생략 ...
task("openBrowser") {
description = "open browser to the running application"
doLast {
val port: Int = 8080
val contextName = "contextName"
val url: URL = URL("http://localhost:$port/$contextName/")
Desktop.getDesktop().browse(url.toURI())
}
}