summaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorJosh Suereth <joshua.suereth@gmail.com>2011-12-05 15:52:10 -0500
committerJosh Suereth <joshua.suereth@gmail.com>2011-12-05 15:52:10 -0500
commit47fb0d381022bda800b7f8ee234224aa20020e4a (patch)
treedc34f3c6ac712adcf829cb7ab8399975fdae4ed4 /project
parent01fffafac5f8184fc6abc4268a2b2d1a2503d5ca (diff)
downloadscala-47fb0d381022bda800b7f8ee234224aa20020e4a.tar.gz
scala-47fb0d381022bda800b7f8ee234224aa20020e4a.tar.bz2
scala-47fb0d381022bda800b7f8ee234224aa20020e4a.zip
Adding SHA resolve to the SBT build so that we don't need the push/pull binary libs script anymore. Only pull is implemented.
Diffstat (limited to 'project')
-rw-r--r--project/Build.scala4
-rw-r--r--project/ShaResolve.scala57
-rw-r--r--project/plugins.sbt2
3 files changed, 61 insertions, 2 deletions
diff --git a/project/Build.scala b/project/Build.scala
index dd75b92734..6ffdffa005 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -141,7 +141,7 @@ object ScalaBuild extends Build with Layers {
//commands += Release.setStarrHome
)
// Note: Root project is determined by lowest-alphabetical project that has baseDirectory as file("."). we use aaa_ to 'win'.
- lazy val aaa_root = Project("scala", file(".")) settings(projectSettings: _*)
+ lazy val aaa_root = Project("scala", file(".")) settings(projectSettings: _*) settings(ShaResolve.settings: _*)
// External dependencies used for various projects
lazy val externalDeps: Setting[_] = libraryDependencies <<= (sbtVersion)(v =>
@@ -206,7 +206,7 @@ object ScalaBuild extends Build with Layers {
// Need a report on this...
// TODO - Resolve STARR from a repo..
- lazy val STARR = scalaInstance <<= appConfiguration map { app =>
+ lazy val STARR = scalaInstance <<= (appConfiguration, ShaResolve.pullBinaryLibs in ThisBuild) map { (app, _) =>
val launcher = app.provider.scalaProvider.launcher
val library = file("lib/scala-library.jar")
val compiler = file("lib/scala-compiler.jar")
diff --git a/project/ShaResolve.scala b/project/ShaResolve.scala
new file mode 100644
index 0000000000..2b7fafd576
--- /dev/null
+++ b/project/ShaResolve.scala
@@ -0,0 +1,57 @@
+import sbt._
+
+import Build._
+import Keys._
+import Project.Initialize
+import scala.collection.{ mutable, immutable }
+
+
+
+
+/** Helpers to resolve SHA artifacts from typesafe repo. */
+object ShaResolve {
+ import dispatch.{Http,url}
+ val remote_urlbase="http://typesafe.artifactoryonline.com/typesafe/scala-sha-bootstrap/org/scala-lang/bootstrap"
+
+ val pullBinaryLibs = TaskKey[Unit]("pull-binary-libs", "Pulls binary libs by the SHA key.")
+ val pushBinaryLibs = TaskKey[Unit]("push-binary-libs", "Pushes binary libs whose SHA has changed.")
+
+
+ def settings: Seq[Setting[_]] = Seq(
+ pullBinaryLibs in ThisBuild <<= (baseDirectory, streams) map resolveLibs
+ )
+
+ def resolveLibs(dir: File, s: TaskStreams): Unit = {
+ for {
+ (file, name) <- dir ** "*.desired.sha1" x relativeTo(dir)
+ uri = name.dropRight(13)
+ jar = dir / uri
+ if !jar.exists || !isValidSha(file)
+ sha = getShaFromShafile(file)
+ } pullFile(jar, sha + "/" + uri, s)
+ }
+
+ def getShaFromShafile(file: File): String = (IO read file split "\\s" headOption) getOrElse error("No SHA found for " + file)
+
+
+ def isValidSha(file: File): Boolean =
+ try (Process(Seq("shasum", "-p", "--check", file.getAbsolutePath), Some(file.getParentFile)).!! contains "OK")
+ catch {
+ case t: Exception => false
+ }
+
+
+ def pullFile(file: File, uri: String, s: TaskStreams): Unit = {
+ val url = remote_urlbase + "/" + uri
+ val fous = new java.io.FileOutputStream(file)
+ s.log.info("Pulling [" + url + "] to [" + file + "]")
+ try Http(dispatch.url(url) >>> fous) finally fous.close()
+ }
+
+ def pushFile(file: File, uri: String, user: String, pw: String): Unit = {
+ val url = remote_urlbase + "/" + uri
+ val sender = dispatch.url(url).PUT.as(user,pw) <<< (file, "application/java-archive")
+ // TODO - output to logger.
+ Http(sender >>> System.out)
+ }
+}
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 2dfee4b5c9..b49ece7527 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -4,4 +4,6 @@ resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
+libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6"
+