summaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorJosh Suereth <joshua.suereth@gmail.com>2012-06-18 22:26:31 -0400
committerJosh Suereth <joshua.suereth@gmail.com>2012-06-18 22:26:31 -0400
commit82032eb2696c44490d8504059dc95790225f79bf (patch)
tree40526ca882a9d703d46ade0cd62cc8e1eb84a87f /project
parent48fc0393808408cd974a80d6ca65b33003599e14 (diff)
downloadscala-82032eb2696c44490d8504059dc95790225f79bf.tar.gz
scala-82032eb2696c44490d8504059dc95790225f79bf.tar.bz2
scala-82032eb2696c44490d8504059dc95790225f79bf.zip
Final clean up to get the build/testing working again.
Diffstat (limited to 'project')
-rw-r--r--project/Build.scala14
-rw-r--r--project/Release.scala28
-rw-r--r--project/ShaResolve.scala70
-rw-r--r--project/Testing.scala7
4 files changed, 82 insertions, 37 deletions
diff --git a/project/Build.scala b/project/Build.scala
index 6a69e00da2..58d322108b 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -8,7 +8,7 @@ import Release._
object ScalaBuild extends Build with Layers with Packaging with Testing {
// Build wide settings:
- override lazy val settings = super.settings ++ Versions.settings ++ RemoteDependencies.buildSettings(Set(scalacheck), fullQuickScalaReference) ++ Seq(
+ override lazy val settings = super.settings ++ Versions.settings ++ Seq(
autoScalaLibrary := false,
resolvers += Resolver.url(
"Typesafe nightlies",
@@ -86,7 +86,6 @@ object ScalaBuild extends Build with Layers with Packaging with Testing {
},
// TODO - Make exported products == makeDist so we can use this when creating a *real* distribution.
commands += Release.pushStarr
- //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: _*) settings(ShaResolve.settings: _*)
@@ -99,6 +98,11 @@ object ScalaBuild extends Build with Layers with Packaging with Testing {
)
)
+ def fixArtifactSrc(dir: File, name: String) = name match {
+ case x if x startsWith "scala-" => dir / "src" / (name drop 6)
+ case x => dir / "src" / name
+ }
+
// These are setting overrides for most artifacts in the Scala build file.
def settingOverrides: Seq[Setting[_]] = publishSettings ++ Seq(
crossPaths := false,
@@ -110,8 +114,8 @@ object ScalaBuild extends Build with Layers with Packaging with Testing {
target <<= (baseDirectory, name) apply (_ / "target" / _),
(classDirectory in Compile) <<= target(_ / "classes"),
javacOptions ++= Seq("-target", "1.5", "-source", "1.5"),
- scalaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _),
- javaSource in Compile <<= (baseDirectory, name) apply (_ / "src" / _),
+ scalaSource in Compile <<= (baseDirectory, name) apply fixArtifactSrc,
+ javaSource in Compile <<= (baseDirectory, name) apply fixArtifactSrc,
unmanagedJars in Compile := Seq(),
// Most libs in the compiler use this order to build.
compileOrder in Compile := CompileOrder.JavaThenScala,
@@ -208,6 +212,8 @@ object ScalaBuild extends Build with Layers with Packaging with Testing {
// Things that compile against the compiler.
lazy val compilerDependentProjectSettings = dependentProjectSettings ++ Seq(quickScalaReflectDependency, quickScalaCompilerDependency, addCheaterDependency("scala-compiler"))
+
+ lazy val scalacheck = Project("scalacheck", file(".")) settings(compilerDependentProjectSettings:_*) dependsOn(actors % "provided")
lazy val partestSettings = compilerDependentProjectSettings :+ externalDeps
lazy val partest = Project("partest", file(".")) settings(partestSettings:_*) dependsOn(actors,forkjoin,scalap)
lazy val scalapSettings = compilerDependentProjectSettings ++ Seq(
diff --git a/project/Release.scala b/project/Release.scala
index 9d4d4ab09c..feab8bdc8c 100644
--- a/project/Release.scala
+++ b/project/Release.scala
@@ -5,12 +5,26 @@ object Release {
// TODO - Just make the STARR artifacts and dump the sha1 files.
+ val starrLibs = Seq("scala-library.jar", "scala-reflect.jar", "scala-compiler.jar", "jline.jar")
- lazy val pushStarr = Command.command("push-starr") { (state: State) =>
- // TODO do something
- // Revert to previous project state.
- state
- }
-
-
+ val pushStarr = Command.command("new-starr") { (state: State) =>
+ /*val extracted = Project.extract(state)
+ import extracted._
+ // First run tests
+ val (s1, result) = runTask(test in Test, state)
+ // If successful, package artifacts
+ val (s2, distDir) = runTask(makeExplodedDist, s1)
+ // Then copy new libs in place
+ val bd = extracted get baseDirectory
+ for {
+ jarName <- starrLibs
+ jar = distDir / "lib" / jarName
+ if jar.exists
+ } IO.copyFile(jar, bd / "lib" / jarName)
+ // Invalidate SHA1 files.
+ ShaResolve.removeInvalidShaFiles(bd)
+ // Now run tests *again*?
+ s2*/
+ state
+ }
}
diff --git a/project/ShaResolve.scala b/project/ShaResolve.scala
index e6824ee464..cea2b2d6cc 100644
--- a/project/ShaResolve.scala
+++ b/project/ShaResolve.scala
@@ -7,6 +7,7 @@ import scala.collection.{ mutable, immutable }
import scala.collection.parallel.CompositeThrowable
import java.security.MessageDigest
+case class Credentials(user: String, pw: String)
/** Helpers to resolve SHA artifacts from typesafe repo. */
object ShaResolve {
@@ -19,7 +20,8 @@ object ShaResolve {
def settings: Seq[Setting[_]] = Seq(
binaryLibCache in ThisBuild := file(System.getProperty("user.home")) / ".sbt" / "cache" / "scala",
- pullBinaryLibs in ThisBuild <<= (baseDirectory, binaryLibCache, streams) map resolveLibs
+ pullBinaryLibs in ThisBuild <<= (baseDirectory, binaryLibCache, streams) map resolveLibs,
+ pushBinaryLibs in ThisBuild <<= (baseDirectory, streams) map getCredentialsAndPushFiles
)
def resolveLibs(dir: File, cacheDir: File, s: TaskStreams): Unit = loggingParallelExceptions(s) {
@@ -33,6 +35,34 @@ object ShaResolve {
} pullFile(jar, sha + "/" + uri, cacheDir, sha, s)
}
+ /** This method removes all SHA1 files that don't match their corresponding JAR. */
+ def removeInvalidShaFiles(dir: File): Unit = {
+ val files = (dir / "test" / "files" ** "*.desired.sha1") +++ (dir / "lib" ** "*.desired.sha1")
+ for {
+ (file, name) <- (files x relativeTo(dir)).par
+ uri = name.dropRight(13).replace('\\', '/')
+ jar = dir / uri
+ if !jar.exists || !isValidSha(file)
+ } IO.delete(jar)
+ }
+ def getCredentials: Credentials = System.out.synchronized {
+ val user = (SimpleReader.readLine("Please enter your STARR username> ") getOrElse error("No username provided."))
+ val password = (SimpleReader.readLine("Please enter your STARR password> ", Some('*')) getOrElse error("No password provided."))
+ Credentials(user, password)
+ }
+
+ def getCredentialsAndPushFiles(dir: File, s: TaskStreams): Unit =
+ pushFiles(dir, getCredentials, s)
+
+ def pushFiles(dir: File, cred: Credentials, s: TaskStreams): Unit = loggingParallelExceptions(s) {
+ val files = (dir / "test" / "files" ** "*.jar") +++ (dir / "lib" ** "*.jar")
+ for {
+ (jar, name) <- (files x relativeTo(dir)).par
+ shafile = dir / (name + ".desired.sha1")
+ if !shafile.exists || !isValidSha(shafile)
+ } pushFile(jar, name, cred, s)
+ }
+
@inline final def loggingParallelExceptions[U](s: TaskStreams)(f: => U): U = try f catch {
case t: CompositeThrowable =>
s.log.error("Error during parallel execution, GET READY FOR STACK TRACES!!")
@@ -60,24 +90,17 @@ object ShaResolve {
sha
}
- // TODO - Prettier way of doing this...
- private def convertToHex(data: Array[Byte]): String = {
+ def convertToHex(data: Array[Byte]): String = {
+ def byteToHex(b: Int) =
+ if ((0 <= b) && (b <= 9)) ('0' + b).toChar
+ else ('a' + (b-10)).toChar
val buf = new StringBuffer
- for (i <- 0 until data.length) {
- var halfbyte = (data(i) >>> 4) & 0x0F;
- var two_halfs = 0;
- while(two_halfs < 2) {
- if ((0 <= halfbyte) && (halfbyte <= 9))
- buf.append(('0' + halfbyte).toChar)
- else
- buf.append(('a' + (halfbyte - 10)).toChar);
- halfbyte = data(i) & 0x0F;
- two_halfs += 1
- }
- }
- return buf.toString
- }
-
+ for (i <- 0 until data.length) {
+ buf append byteToHex((data(i) >>> 4) & 0x0F)
+ buf append byteToHex(data(i) & 0x0F)
+ }
+ buf.toString
+ }
// Parses a sha file into a file and a sha.
def parseShaFile(file: File): (File, String) =
IO.read(file).split("\\s") match {
@@ -110,10 +133,15 @@ object ShaResolve {
IO.copyFile(cachedFile, file)
}
- 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")
+ // Pushes a file and writes the new .desired.sha1 for git.
+ def pushFile(file: File, uri: String, cred: Credentials, s: TaskStreams): Unit = {
+ val sha = calculateSha(file)
+ val url = remote_urlbase + "/" + sha + "/" + uri
+ val sender = dispatch.url(url).PUT.as(cred.user,cred.pw) <<< (file, "application/java-archive")
// TODO - output to logger.
Http(sender >>> System.out)
+ val shafile = file.getParentFile / (file.getName + ".desired.sha1")
+ IO.touch(shafile)
+ IO.write(shafile, sha + " ?" + file.getName)
}
}
diff --git a/project/Testing.scala b/project/Testing.scala
index 61676c81bd..cec1d8c60b 100644
--- a/project/Testing.scala
+++ b/project/Testing.scala
@@ -7,9 +7,6 @@ import ScalaBuildKeys._
/** All settings/projects relating to testing. */
trait Testing { self: ScalaBuild.type =>
- /* lazy val scalacheckSettings: Seq[Setting[_]] = Seq(fullQuickScalaReference, crossPaths := false)*/
- lazy val scalacheck = uri("git://github.com/jsuereth/scalacheck.git#scala-build")
-
lazy val testsuiteSettings: Seq[Setting[_]] = compilerDependentProjectSettings ++ partestTaskSettings ++ VerifyClassLoad.settings ++ Seq(
unmanagedBase <<= baseDirectory / "test/files/lib",
fullClasspath in VerifyClassLoad.checkClassLoad <<= (fullClasspath in scalaLibrary in Runtime).identity,
@@ -32,12 +29,12 @@ trait Testing { self: ScalaBuild.type =>
val testsuite = (
Project("testsuite", file("."))
settings (testsuiteSettings:_*)
- dependsOn (scalaLibrary, scalaCompiler, fjbg, partest, scalacheck)
+ dependsOn (scalaLibrary, scalaCompiler, fjbg, partest, scalacheck, actorsMigration)
)
val continuationsTestsuite = (
Project("continuations-testsuite", file("."))
settings (continuationsTestsuiteSettings:_*)
- dependsOn (partest, scalaLibrary, scalaCompiler, fjbg)
+ dependsOn (partest, scalaLibrary, scalaCompiler, fjbg, actorsMigration)
)
}