Permalink
Browse files

Added dist task for agent

  • Loading branch information...
1 parent f3049b1 commit 07c05bd40aa56a5761211271f0d601a1dfe2bf19 @djspiewak committed Nov 10, 2011
Showing with 40 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 agent/bin/server
  3. +2 −0 agent/bin/server.bat
  4. +32 −0 agent/build.sbt
  5. +2 −0 project/Project.scala
View
@@ -1,2 +1,3 @@
target/
project/target/
+dist/
View
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+java -jar <RUNTIME_CLASSPATH> com.codecommit.cccp.agent.Main $*
View
@@ -0,0 +1,2 @@
+REM TODO
+java -jar <RUNTIME_CLASSPATH> com.codecommit.cccp.agent.Main
View
@@ -1,3 +1,5 @@
+import IO._
+
name := "cccp-agent"
libraryDependencies ++= Seq(
@@ -11,3 +13,33 @@ resolvers ++= Seq(
"JBoss" at "http://repository.jboss.org/nexus/content/groups/public/",
"Akka" at "http://akka.io/repository/",
"GuiceyFruit" at "http://guiceyfruit.googlecode.com/svn/repo/releases/")
+
+stage <<= (dependencyClasspath in Runtime, exportedProducts in Runtime) map { (depCP, exportedCP) =>
+ // this task "borrowed" from ENSIME (thanks, Aemon!)
+ val agent = Path("agent")
+ val log = LogManager.defaultScreen
+ delete(file("dist"))
+ log.info("Copying runtime environment to ./dist....")
+ createDirectories(List(
+ file("agent/dist"),
+ file("agent/dist/bin"),
+ file("agent/dist/lib")))
+ // Copy the runtime jars
+ val deps = (depCP ++ exportedCP).map(_.data)
+ copy(deps x flat(agent / "dist" / "lib"))
+ // Grab all jars..
+ val cpLibs = (agent / "dist" / "lib" ** "*.jar").get.flatMap(_.relativeTo(agent / "dist"))
+ def writeScript(classpath:String, from:String, to:String) {
+ val tmplF = new File(from)
+ val tmpl = read(tmplF)
+ val s = tmpl.replace("<RUNTIME_CLASSPATH>", classpath)
+ val f = new File(to)
+ write(f, s)
+ f.setExecutable(true)
+ }
+ // Expand the server invocation script templates.
+ writeScript(cpLibs.mkString(":").replace("\\", "/"), "agent/bin/server", "agent/dist/bin/server")
+ writeScript("\"" + cpLibs.mkString(";").replace("/", "\\") + "\"", "agent/bin/server.bat", "agent/dist/bin/server.bat")
+ // copyFile(root / "README.md", root / "dist" / "README.md")
+ // copyFile(root / "LICENSE", root / "dist" / "LICENSE")
+}
View
@@ -6,5 +6,7 @@ object CCCPBuild extends Build {
lazy val server = Project(id = "cccp-server", base = file("server"))
lazy val agent = Project(id = "cccp-agent", base = file("agent")) dependsOn server
lazy val jeditClient = Project(id = "cccp-jedit-client", base = file("clients/jedit"))
+
+ val stage = TaskKey[Unit]("stage", "Copy files into staging directory for a release.")
}

0 comments on commit 07c05bd

Please sign in to comment.