summaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorJosh Suereth <joshua.suereth@gmail.com>2012-04-03 11:36:07 -0400
committerJosh Suereth <joshua.suereth@gmail.com>2012-04-03 11:36:07 -0400
commit4467438a58a3ce0342c1ab608b02b0f880c61aaf (patch)
tree24fbaa747309b4ea7eba029b9ccfafc62cd986ad /project
parent9894b2c9bcfe9cec0a6853b69148e0c8b5a2508d (diff)
downloadscala-4467438a58a3ce0342c1ab608b02b0f880c61aaf.tar.gz
scala-4467438a58a3ce0342c1ab608b02b0f880c61aaf.tar.bz2
scala-4467438a58a3ce0342c1ab608b02b0f880c61aaf.zip
Fixed up versioning scheme.
SBT build should now mimic ant build for versions.
Diffstat (limited to 'project')
-rw-r--r--project/Build.scala6
-rw-r--r--project/Layers.scala6
-rw-r--r--project/Release.scala106
-rw-r--r--project/ShaResolve.scala2
-rw-r--r--project/Versions.scala45
5 files changed, 51 insertions, 114 deletions
diff --git a/project/Build.scala b/project/Build.scala
index dd9f9f6c04..76df76d38c 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>
@@ -111,7 +111,7 @@ object ScalaBuild extends Build with Layers {
)
// Settings for root project. These are aggregate tasks against the rest of the build.
- def projectSettings: Seq[Setting[_]] = publishSettings ++ Versions.settings ++ Seq(
+ def projectSettings: Seq[Setting[_]] = publishSettings ++ Seq(
doc in Compile <<= (doc in documentation in Compile).identity,
// These next two aggregate commands on several projects and return results that are to be ignored by remaining tasks.
compile in Compile <<= compiledProjects.map(p => compile in p in Compile).join.map(_.head),
diff --git a/project/Layers.scala b/project/Layers.scala
index d39e58014c..b15b327895 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, streams) map Versions.generateVersionPropertiesFile("library.properties"),
referenceScala
)
@@ -70,7 +72,7 @@ trait Layers extends Build {
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, 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/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
index fdfc6304fd..5f1fe0cacc 100644
--- a/project/Versions.scala
+++ b/project/Versions.scala
@@ -7,35 +7,68 @@ 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 = TaskKey[BaseBuildNumber]("scala-build-number-props")
+ 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 = TaskKey[String]("scala-maven-version", "The maven version number.")
+ 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 map loadBuildNumberProps,
+ buildNumberProps <<= buildNumberFile apply loadBuildNumberProps,
buildRelease := Option(System.getProperty("build.release")) map (!_.isEmpty) getOrElse false,
mavenSuffix <<= buildRelease apply pickMavenSuffix,
- mavenVersion <<= (buildNumberProps, mavenSuffix) map makeMavenVersion,
+ 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
+ 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, 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 || !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 {