Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use BrowerLauncher2 to open URLs.

  • Loading branch information...
commit dea21959c0786deae2684c5d8188fd96c35f6114 1 parent 22778d9
@pr1001 pr1001 authored
Showing with 6 additions and 14 deletions.
  1. +1 −0  build.sbt
  2. +5 −14 src/main/scala/cloudbees.scala
View
1  build.sbt
@@ -18,6 +18,7 @@ scalacOptions += "-deprecation"
libraryDependencies ++= Seq(
"com.cloudbees" % "cloudbees-api-client-nodeps" % "1.1.2" % "compile",
+ "edu.stanford.ejalbert" % "BrowserLauncher2" % "1.3" % "compile",
"org.scala-tools.testing" % "specs" % "1.6.1" % "test"
)
View
19 src/main/scala/cloudbees.scala
@@ -2,6 +2,9 @@ package cloudbees
import sbt._, Keys._, Project.Initialize
import com.cloudbees.api.{BeesClient,HashWriteProgress}
+import edu.stanford.ejalbert.{BrowserLauncher => BL}
+
+object BrowserLauncher extends BL()
object Plugin extends Plugin {
import CloudBees._
@@ -62,7 +65,7 @@ object Plugin extends Plugin {
val result = client().applicationDeployWar(to, null, null, war.asFile.getAbsolutePath, null, true, new HashWriteProgress)
s.log.info("Application avalible at %s".format(result.getUrl))
if (open) {
- openApp(result.getUrl)
+ BrowserLauncher.openURLinBrowser(result.getUrl)
}
} else sys.error("There was a problem locating the WAR file for this project")
}
@@ -70,7 +73,7 @@ object Plugin extends Plugin {
def openTask = (username, applicationId) map { (user, app) => for {
u <- user
a <- app
- } openApp("http://" + a + "." + u + ".cloudbees.net")
+ } BrowserLauncher.openURLinBrowser("http://" + a + "." + u + ".cloudbees.net")
}
/***** internal *****/
@@ -82,16 +85,4 @@ object Plugin extends Plugin {
value.getOrElse {
sys.error("%s setting is required".format(setting.key.label))
}
- private def openApp(url: String) {
- // VERY roughly taken from the Ruby Launchy library
- val command = System.getProperty("os.name") match {
- case os if os.toLowerCase contains "os x" => "open"
- case os if os.toLowerCase contains "windows" => "start /b"
- case os if os.toLowerCase contains "cygwin" => "cmd /C start /b"
- case _ => "xdg-open"
- }
- val str = command + " " + url + ""
- Process.stringToProcess(str).run
- // don't destroy the Process after running since that seems to prevent it from running at all
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.