Skip to content

Instantly share code, notes, and snippets.

@ReSTARTR
Created May 9, 2011 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ReSTARTR/962534 to your computer and use it in GitHub Desktop.
Save ReSTARTR/962534 to your computer and use it in GitHub Desktop.
DotCloud sbt Project sample
import sbt._
class AppnameProject(info: ProjectInfo) extends DefaultWebProject(info) {
val JETTY7 = "7.3.1.v20110307"
val servletapi = "javax.servlet" % "servlet-api" % "2.5" % "compile"
val jetty7Server = "org.eclipse.jetty" % "jetty-server" % JETTY7 % "compile,test"
val jetty7Servlets = "org.eclipse.jetty" % "jetty-servlets" % JETTY7 % "compile,test"
val jetty7Webapp = "org.eclipse.jetty" % "jetty-webapp" % JETTY7 % "compile,test"
val copyDirectory = path("release")
val copyFileName = copyDirectory / "root.war"
val dotApplicationName = "APPNAME"
val dotServiceName = dotApplicationName + ".SERVNAME"
import Process._
lazy val dot_create = task {
val lists:Stream[String] = "dotcloud list" lines_!;
def exists(x:String) = { lists.exists( _.indexOf(x)>=0) }
exists(dotApplicationName) match {
case false => "dotcloud create " + dotApplicationName ! log
case _ => log.warn("application is already exists.: " + dotApplicationName )
}
exists(dotServiceName) match {
case false => {
val res = "dotcloud deploy -t java " + dotServiceName !!;
res.indexOf("Created") >= 0 match {
case true => log.info("success to deproy")
case _ => log.info("fail to deproy")
}
}
case _ => log.warn("service is already exists.")
}
None
}
lazy val dot_prepare = task {
log.info("mkdir")
"mkdir " + copyDirectory !;
log.info( "copy war file to " + copyFileName )
val files:Stream[String] = "find ./target -name *.war -exec ls -t {} ;" lines_!;
if (files.length > 0 ) {
"cp " + files.head.toString + " " + copyFileName + "" !
}
None
}
lazy val dot_push = task {
import Process._
log.info("push to dotcloud")
"dotcloud push " + dotServiceName + " " + copyDirectory ! log; None
}.dependsOn(`package`, dot_prepare)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment