summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-05-10 09:40:22 -0700
committerPaul Phillips <paulp@improving.org>2012-05-10 09:40:22 -0700
commit782dad7619993d5f9ea358c41cd764ad0c692162 (patch)
tree4740f6028376e375e13425f3a2d6235bc134f906
parent391524d99c5caaced0e1aacbb867ff15fca7e756 (diff)
parent4bbbaa0240376c42ef6870f9321a99ae12448012 (diff)
downloadscala-782dad7619993d5f9ea358c41cd764ad0c692162.tar.gz
scala-782dad7619993d5f9ea358c41cd764ad0c692162.tar.bz2
scala-782dad7619993d5f9ea358c41cd764ad0c692162.zip
Merge commit 'refs/pull/524/head'
-rw-r--r--project/Build.scala11
-rw-r--r--project/Layers.scala7
-rw-r--r--project/Partest.scala2
-rw-r--r--project/Release.scala106
-rw-r--r--project/ShaResolve.scala2
-rw-r--r--project/Versions.scala142
-rw-r--r--project/project/Build.scala2
-rw-r--r--src/partest/scala/tools/partest/nest/SBTRunner.scala18
8 files changed, 169 insertions, 121 deletions
diff --git a/project/Build.scala b/project/Build.scala
index 25fb31cf5b..ea0e84f0cc 100644
--- a/project/Build.scala
+++ b/project/Build.scala
@@ -23,7 +23,7 @@ object ScalaBuild extends Build with Layers {
lazy val buildFixed = AttributeKey[Boolean]("build-uri-fixed")
// Build wide settings:
- override lazy val settings = super.settings ++ Seq(
+ override lazy val settings = super.settings ++ Versions.settings ++ Seq(
autoScalaLibrary := false,
resolvers += Resolver.url(
"Typesafe nightlies",
@@ -34,7 +34,7 @@ object ScalaBuild extends Build with Layers {
ScalaToolsSnapshots
),
organization := "org.scala-lang",
- version := "2.10.0-SNAPSHOT",
+ version <<= Versions.mavenVersion,
pomExtra := <xml:group>
<inceptionYear>2002</inceptionYear>
<licenses>
@@ -148,13 +148,14 @@ object ScalaBuild extends Build with Layers {
lazy val externalDeps: Setting[_] = libraryDependencies <<= (sbtVersion)(v =>
Seq(
"org.apache.ant" % "ant" % "1.8.2",
- "org.scala-tools.sbt" % "compiler-interface" % v % "provided"
+ "org.scala-sbt" % "compiler-interface" % v % "provided"
)
)
// These are setting overrides for most artifacts in the Scala build file.
def settingOverrides: Seq[Setting[_]] = publishSettings ++ Seq(
crossPaths := false,
+ autoScalaLibrary := false,
publishArtifact in packageDoc := false,
publishArtifact in packageSrc := false,
target <<= (baseDirectory, name) apply (_ / "target" / _),
@@ -327,7 +328,7 @@ object ScalaBuild extends Build with Layers {
// Testing
// --------------------------------------------------------------
/* lazy val scalacheckSettings: Seq[Setting[_]] = Seq(fullQuickScalaReference, crossPaths := false)*/
- lazy val scalacheck = uri("git://github.com/rickynils/scalacheck.git")
+ 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",
@@ -518,7 +519,7 @@ object ScalaBuild extends Build with Layers {
// Add in some more dependencies
makeDistMappings <<= (makeDistMappings,
packageBin in swing in Compile) map {
- (dist, s, d) =>
+ (dist, s) =>
dist ++ Seq(s -> "lib/scala-swing.jar")
},
makeDist <<= (makeDistMappings, baseDirectory, streams) map { (maps, dir, s) =>
diff --git a/project/Layers.scala b/project/Layers.scala
index d39e58014c..3d6d780f8f 100644
--- a/project/Layers.scala
+++ b/project/Layers.scala
@@ -16,6 +16,8 @@ trait Layers extends Build {
def fjbg: Project
/** A setting that adds some external dependencies. */
def externalDeps: Setting[_]
+ /** The root project. */
+ def aaa_root: Project
/** Creates a reference Scala version that can be used to build other projects. This takes in the raw
* library, compiler and fjbg libraries as well as a string representing the layer name (used for compiling the compile-interface).
@@ -57,7 +59,7 @@ trait Layers extends Build {
// TODO - Allow other scalac option settings.
scalacOptions in Compile <++= (scalaSource in Compile) map (src => Seq("-sourcepath", src.getAbsolutePath)),
classpathOptions := ClasspathOptions.manual,
- resourceGenerators in Compile <+= (baseDirectory, version, resourceManaged, gitRunner, streams) map Release.generatePropertiesFile("library.properties"),
+ resourceGenerators in Compile <+= (resourceManaged, Versions.scalaVersions, skip in Compile, streams) map Versions.generateVersionPropertiesFile("library.properties"),
referenceScala
)
@@ -68,9 +70,8 @@ trait Layers extends Build {
resourceDirectory in Compile <<= baseDirectory apply (_ / "src" / "compiler"),
unmanagedSourceDirectories in Compile <+= (baseDirectory) apply (_ / "src" / "msil"),
defaultExcludes := ("tests"),
- javacOptions ++= Seq("-source", "1.4"),
defaultExcludes in unmanagedResources := "*.scala",
- resourceGenerators in Compile <+= (baseDirectory, version, resourceManaged, gitRunner, streams) map Release.generatePropertiesFile("compiler.properties"),
+ resourceGenerators in Compile <+= (resourceManaged, Versions.scalaVersions, skip in Compile, streams) map Versions.generateVersionPropertiesFile("compiler.properties"),
// Note, we might be able to use the default task, but for some reason ant was filtering files out. Not sure what's up, but we'll
// stick with that for now.
unmanagedResources in Compile <<= (baseDirectory) map {
diff --git a/project/Partest.scala b/project/Partest.scala
index ad8047fa00..bbc160a41d 100644
--- a/project/Partest.scala
+++ b/project/Partest.scala
@@ -115,7 +115,7 @@ object partest {
}
}
- def partestRunnerTask(classpath: ScopedTask[Classpath], javacOptions: ScopedTask[Seq[String]]): Project.Initialize[Task[PartestRunner]] =
+ def partestRunnerTask(classpath: ScopedTask[Classpath], javacOptions: SettingKey[Seq[String]]): Project.Initialize[Task[PartestRunner]] =
(classpath, javacOptions) map ((cp, opts) => new PartestRunner(Build.data(cp), opts mkString " "))
}
diff --git a/project/Release.scala b/project/Release.scala
index 5ed77548fc..1a17956c13 100644
--- a/project/Release.scala
+++ b/project/Release.scala
@@ -1,115 +1,15 @@
import sbt._
import Keys._
-import _root_.com.jsuereth.git.GitRunner
object Release {
- // TODO - move more of the dist project over here...
+ // TODO - Just make the STARR artifacts and dump the sha1 files.
lazy val pushStarr = Command.command("push-starr") { (state: State) =>
- def f(s: Setting[_]): Setting[_] = s.key.key match {
- case version.key => // TODO - use full version
- s.asInstanceOf[Setting[String]].mapInit( (_,_) => timeFormat format (new java.util.Date))
- case organization.key =>
- s.asInstanceOf[Setting[String]].mapInit( (_,_) => "org.scala-lang.bootstrapp")
- // TODO - Switch publish repo to be typesafe starr repo.
- case publishTo.key =>
- s.asInstanceOf[Setting[Option[Resolver]]].mapInit((_,_) => Some("Starr Repo" at "http://typesafe.artifactoryonline.com/typesafe/starr-releases/"))
- case _ => s
- }
- val extracted = Project.extract(state)
- import extracted._
- // Swap version on projects
- val transformed = session.mergeSettings map ( s => f(s) )
- val newStructure = Load.reapply(transformed, structure)
- val newState = Project.setProject(session, newStructure, state)
- // TODO - Run tasks. Specifically, push scala-compiler + scala-library. *Then* bump the STARR version locally.
- // The final course of this command should be:
- // publish-local
- // Project.evaluateTask(publishLocal, newState)
- // bump STARR version setting
- // TODO - Define Task
- // Rebuild quick + test to ensure it works
- // Project.evaluateTask(test, newState)
- // push STARR remotely
- Project.evaluateTask(publish, newState)
+ // TODO do something
// Revert to previous project state.
- Project.setProject(session, structure, state)
+ state
}
- // TODO - Autocomplete
- /*lazy val setStarrHome = Command.single("set-starr-home") { (state: State, homeDir: String) =>
- def f(s: Setting[_]): Setting[_] =
- if(s.key.key == scalaInstance.key) {
- s.asInstanceOf[Setting[ScalaInstance]] mapInit { (key, value) =>
- if(value.version == "starr")
- scalaInstance <<= appConfiguration map { app =>
- val launcher = app.provider.scalaProvider.launcher
- ScalaInstance("starr", new File(homeDir), launcher)
- }
- else value
- }
- } else s
- val extracted = Project.extract(state)
- import extracted._
- val transformed = session.mergeSettings map f
- val newStructure = Load.reapply(transformed, structure)
- Project.setProject(session, newStructure, state)
- }*/
-
- lazy val timeFormat = {
- val formatter = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss")
- formatter.setTimeZone(java.util.TimeZone.getTimeZone("GMT"))
- formatter
- }
-
- /** This generates a properties file, if it does not already exist, with the maximum lastmodified timestamp
- * of any source file. */
- def generatePropertiesFile(name: String)(baseDirectory: File, version: String, dir: File, git: GitRunner, s: TaskStreams): Seq[File] = {
- // TODO - We can probably clean this up by moving caching bits elsewhere perhaps....
- val target = dir / name
- // TODO - Regenerate on triggers, like recompilation or something...
- val fullVersion = makeFullVersionString(baseDirectory, version, git, s)
- def hasSameVersion: Boolean = {
- val props = new java.util.Properties
- val in = new java.io.FileInputStream(target)
- try props.load(in) finally in.close()
- def withoutDate(s: String): String = s.reverse.dropWhile (_ != '.').reverse
- withoutDate(fullVersion) == withoutDate(props getProperty "version.number")
- }
- if (!target.exists || !hasSameVersion) {
- makePropertiesFile(target, fullVersion)
- }
- target :: Nil
- }
-
- // This creates the *.properties file used to determine the current version of scala at runtime. TODO - move these somewhere utility like.
- def makePropertiesFile(f: File, version: String): Unit =
- IO.write(f, "version.number = "+version+"\ncopyright.string = Copyright 2002-2011, LAMP/EPFL")
-
- def makeFullVersionString(baseDirectory: File, baseVersion: String, git: GitRunner, s: TaskStreams) = baseVersion+"."+getGitRevision(baseDirectory, git, currentDay, s)
-
- // TODO - do we want this in the build number?
- def currentDay = (new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss")) format (new java.util.Date)
-
-
-
- def getGitRevision(baseDirectory: File, git: GitRunner, date: String, s: TaskStreams) = {
-
- val mergeBase = {
- // TODO - Cache this value.
- // git("merge-base","v2.8.2","v2.9.1","master")(baseDirectory, s.log)
- "df13e31bbb"
- }
- // current commit sha
- val sha =
- git("rev-list", "-n", "1", "HEAD")(baseDirectory, s.log)
-
- val commits =
- git("--no-pager", "log", "--pretty=oneline", mergeBase +"..HEAD")(baseDirectory, s.log) split "[\r\n]+" size
-
- "rdev-%d-%s-g%s" format (commits, date, sha.substring(0,7))
- }
-
}
diff --git a/project/ShaResolve.scala b/project/ShaResolve.scala
index f54e96c0c6..e6824ee464 100644
--- a/project/ShaResolve.scala
+++ b/project/ShaResolve.scala
@@ -40,6 +40,8 @@ object ShaResolve {
throw t
}
+ // TODO - Finish this publishing aspect.
+
def getShaFromShafile(file: File): String = parseShaFile(file)._2
// This should calculate the SHA sum of a file the same as the linux process.
diff --git a/project/Versions.scala b/project/Versions.scala
new file mode 100644
index 0000000000..b588ec55ac
--- /dev/null
+++ b/project/Versions.scala
@@ -0,0 +1,142 @@
+import sbt._
+import Keys._
+import java.util.Properties
+import scala.util.control.Exception.catching
+import java.lang.{NumberFormatException => NFE}
+import java.io.FileInputStream
+import com.jsuereth.git.GitRunner
+import com.jsuereth.git.GitKeys.gitRunner
+
+case class VersionInfo(canonical: String,
+ maven: String,
+ osgi: String)
+
+/** this file is responsible for setting up Scala versioning schemes and updating all the necessary bits. */
+object Versions {
+ val buildNumberFile = SettingKey[File]("scala-build-number-file")
+ // TODO - Make this a setting?
+ val buildNumberProps = SettingKey[BaseBuildNumber]("scala-build-number-props")
+ val buildRelease = SettingKey[Boolean]("scala-build-release", "This is set to true if we're building a release.")
+ val mavenSuffix = SettingKey[String]("scala-maven-suffix", "This is set to whatever maven suffix is required.")
+
+ val gitSha = TaskKey[String]("scala-git-sha", "The sha of the current git commit.")
+ val gitDate = TaskKey[String]("scala-git-date", "The date of the current git commit.")
+
+ val mavenVersion = SettingKey[String]("scala-maven-version", "The maven version number.")
+ val osgiVersion = TaskKey[String]("scala-osgi-version", "The OSGi version number.")
+ val canonicalVersion = TaskKey[String]("scala-canonical-version", "The canonical version number.")
+
+ val scalaVersions = TaskKey[VersionInfo]("scala-version-info", "The scala versions used for this build.")
+
+
+
+ def settings: Seq[Setting[_]] = Seq(
+ buildNumberFile <<= baseDirectory apply (_ / "build.number"),
+ buildNumberProps <<= buildNumberFile apply loadBuildNumberProps,
+ buildRelease := Option(System.getProperty("build.release")) map (!_.isEmpty) getOrElse false,
+ mavenSuffix <<= buildRelease apply pickMavenSuffix,
+ mavenVersion <<= (buildNumberProps, mavenSuffix) apply makeMavenVersion,
+ gitSha <<= (gitRunner, baseDirectory, streams) map getGitSha,
+ gitDate <<= (gitRunner, baseDirectory, streams) map getGitDate,
+ osgiVersion <<= (buildNumberProps, gitDate, gitSha) map makeOsgiVersion,
+ canonicalVersion <<= (buildRelease, mavenVersion, buildNumberProps, gitDate, gitSha) map makeCanonicalVersion,
+ scalaVersions <<= (canonicalVersion, mavenVersion, osgiVersion) map VersionInfo.apply
+ )
+
+
+ /** This generates a properties file, if it does not already exist, with the maximum lastmodified timestamp
+ * of any source file. */
+ def generateVersionPropertiesFile(name: String)(dir: File, versions: VersionInfo, skip: Boolean, s: TaskStreams): Seq[File] = {
+ // TODO - We can probably clean this up by moving caching bits elsewhere perhaps....
+ val target = dir / name
+ // TODO - Regenerate on triggers, like recompilation or something...
+ def hasSameVersion: Boolean = {
+ val props = new java.util.Properties
+ val in = new java.io.FileInputStream(target)
+ try props.load(in) finally in.close()
+ versions.canonical == (props getProperty "version.number")
+ }
+ if (!target.exists || !(skip || hasSameVersion)) {
+ makeVersionPropertiesFile(target, versions)
+ }
+ target :: Nil
+ }
+
+ // This creates the *.properties file used to determine the current version of scala at runtime. TODO - move these somewhere utility like.
+ def makeVersionPropertiesFile(f: File, versions: VersionInfo): Unit =
+ IO.write(f, "version.number = "+versions.canonical+"\n"+
+ "osgi.number = "+versions.osgi+"\n"+
+ "maven.number = "+versions.maven+"\n"+
+ "copyright.string = Copyright 2002-2011, LAMP/EPFL")
+
+ def makeCanonicalVersion(isRelease: Boolean, mvnVersion: String, base: BaseBuildNumber, gitDate: String, gitSha: String): String =
+ if(isRelease) mvnVersion
+ else {
+ val suffix = if(base.bnum > 0) "-%d".format(base.bnum) else ""
+ "%s.%s.%s%s-%s-%s" format (base.major, base.minor, base.patch, suffix, gitDate, gitSha)
+ }
+
+ def makeMavenVersion(base: BaseBuildNumber, suffix: String): String = {
+ val firstSuffix = if(base.bnum > 0) "-%d".format(base.bnum) else ""
+ "%d.%d.%d%s%s" format (base.major, base.minor, base.patch, firstSuffix, suffix)
+ }
+
+ def makeOsgiVersion(base: BaseBuildNumber, gitDate: String, gitSha: String): String = {
+ val suffix = if(base.bnum > 0) "-%d".format(base.bnum) else ""
+ "%s.%s.%s.v%s%s-%s" format (base.major, base.minor, base.patch, gitDate, suffix, gitSha)
+ }
+
+ /** Determines what the maven sufffix should be for this build. */
+ def pickMavenSuffix(isRelease: Boolean): String = {
+ def default = if(isRelease) "" else "-SNAPSHOT"
+ Option(System.getProperty("maven.version.suffix")) getOrElse default
+ }
+
+ /** Loads the build.number properties file into SBT. */
+ def loadBuildNumberProps(file: File): BaseBuildNumber = {
+ val fin = new FileInputStream(file)
+ try {
+ val props = new Properties()
+ props.load(fin)
+ def getProp(name: String): Int =
+ (for {
+ v <- Option(props.getProperty(name))
+ v2 <- catching(classOf[NFE]) opt v.toInt
+ } yield v2) getOrElse sys.error("Could not convert %s to integer!" format (name))
+
+ BaseBuildNumber(
+ major=getProp("version.major"),
+ minor=getProp("version.minor"),
+ patch=getProp("version.patch"),
+ bnum =getProp("version.bnum")
+ )
+ } finally fin.close()
+ }
+
+
+ def getGitDate(git: GitRunner, baseDirectory: File, s: TaskStreams): String = {
+ val lines = getGitLines("log","-1","--format=\"%ci\"")(git,baseDirectory, s)
+ val line = if(lines.isEmpty) sys.error("Could not retreive git commit sha!") else lines.head
+ // Lines *always* start with " for some reason...
+ line drop 1 split "\\s+" match {
+ case Array(date, time, _*) => "%s-%s" format (date.replaceAll("\\-", ""), time.replaceAll(":",""))
+ case _ => sys.error("Could not parse git date: " + line)
+ }
+ }
+
+ def getGitSha(git: GitRunner, baseDirectory: File, s: TaskStreams): String = {
+ val lines = getGitLines("log","-1","--format=\"%H\"", "HEAD")(git,baseDirectory, s)
+ val line = if(lines.isEmpty) sys.error("Could not retreive git commit sha!") else lines.head
+ val noquote = if(line startsWith "\"") line drop 1 else line
+ val nog = if(noquote startsWith "g") noquote drop 1 else noquote
+ nog take 10
+ }
+
+ def getGitLines(args: String*)(git: GitRunner, baseDirectory: File, s: TaskStreams): Seq[String] =
+ git(args: _*)(baseDirectory, s.log) split "[\r\n]+"
+}
+
+
+case class BaseBuildNumber(major: Int, minor: Int, patch: Int, bnum: Int) {
+ override def toString = "BaseBuildNumber(%d.%d.%d-%d)" format (major, minor, patch, bnum)
+}
diff --git a/project/project/Build.scala b/project/project/Build.scala
index 1ceb7e2ef2..bd1250fc39 100644
--- a/project/project/Build.scala
+++ b/project/project/Build.scala
@@ -2,6 +2,6 @@ import sbt._
object PluginDef extends Build {
override def projects = Seq(root)
lazy val root = Project("plugins", file(".")) dependsOn(proguard, git)
- lazy val proguard = uri("git://github.com/jsuereth/xsbt-proguard-plugin.git")
+ lazy val proguard = uri("git://github.com/jsuereth/xsbt-proguard-plugin.git#sbt-0.11")
lazy val git = uri("git://github.com/sbt/sbt-git-plugin.git#scala-build")
}
diff --git a/src/partest/scala/tools/partest/nest/SBTRunner.scala b/src/partest/scala/tools/partest/nest/SBTRunner.scala
index 750e270c18..5d994eeb37 100644
--- a/src/partest/scala/tools/partest/nest/SBTRunner.scala
+++ b/src/partest/scala/tools/partest/nest/SBTRunner.scala
@@ -54,15 +54,17 @@ object SBTRunner extends DirectRunner {
val config = parseArgs(args, CommandLineOptions())
fileManager.SCALAC_OPTS = config.scalacOptions
fileManager.CLASSPATH = config.classpath getOrElse sys.error("No classpath set")
+
+ def findClasspath(jar: String, name: String): Option[String] = {
+ val optJar = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches (".*"+jar+".*\\.jar"))).headOption
+ val optClassDir = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches (".*"+name+File.separator+"classes"))).headOption
+ optJar orElse optClassDir
+ }
// Find scala library jar file...
- val lib: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-library.*\\.jar")).headOption
- fileManager.LATEST_LIB = lib getOrElse sys.error("No scala-library found! Classpath = " + fileManager.CLASSPATH)
- val comp: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-compiler.*\\.jar")).headOption
- fileManager.LATEST_COMP = comp getOrElse sys.error("No scala-compiler found! Classpath = " + fileManager.CLASSPATH)
- val partest: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-partest.*\\.jar")).headOption
- fileManager.LATEST_PARTEST = partest getOrElse sys.error("No scala-partest found! Classpath = " + fileManager.CLASSPATH)
- val actors: Option[String] = (fileManager.CLASSPATH split File.pathSeparator filter (_ matches ".*scala-actors.*\\.jar")).headOption
- fileManager.LATEST_ACTORS = actors getOrElse sys.error("No scala-actors found! Classpath = " + fileManager.CLASSPATH)
+ fileManager.LATEST_LIB = findClasspath("scala-library", "scala-library") getOrElse sys.error("No scala-library found! Classpath = " + fileManager.CLASSPATH)
+ fileManager.LATEST_COMP = findClasspath("scala-compiler", "scala-compiler") getOrElse sys.error("No scala-compiler found! Classpath = " + fileManager.CLASSPATH)
+ fileManager.LATEST_PARTEST = findClasspath("scala-partest", "partest") getOrElse sys.error("No scala-partest found! Classpath = " + fileManager.CLASSPATH)
+ fileManager.LATEST_ACTORS = findClasspath("scala-actors", "actors") getOrElse sys.error("No scala-actors found! Classpath = " + fileManager.CLASSPATH)
// TODO - Do something useful here!!!
fileManager.JAVAC_CMD = "javac"