diff --git a/build.sbt b/build.sbt index f98bb1c97..2bb89248a 100644 --- a/build.sbt +++ b/build.sbt @@ -11,8 +11,8 @@ import Sxr.sxr def commonSettings: Seq[Setting[_]] = Seq( organization := "org.scala-sbt", version := "0.13.8-SNAPSHOT", + scalaVersion in ThisBuild := "2.10.4", publishArtifact in packageDoc := false, - scalaVersion := "2.10.4", publishMavenStyle := false, componentID := None, crossPaths := false, @@ -24,12 +24,8 @@ def commonSettings: Seq[Setting[_]] = Seq( ) def minimalSettings: Seq[Setting[_]] = - commonSettings ++ customCommands ++ Status.settings ++ nightlySettings ++ - publishPomSettings ++ Release.javaVersionCheckSettings ++ - Seq( - crossVersion in update <<= (crossVersion, nightly211) { (cv, n) => if (n) CrossVersion.full else cv }, - resolvers += Resolver.typesafeIvyRepo("releases") - ) + commonSettings ++ customCommands ++ Status.settings ++ + publishPomSettings ++ Release.javaVersionCheckSettings def baseSettings: Seq[Setting[_]] = minimalSettings ++ Seq(projectComponent) ++ baseScalacOptions ++ Licensed.settings ++ Formatting.settings @@ -105,13 +101,15 @@ lazy val apiProj = (project in compilePath / "api"). lazy val controlProj = (project in utilPath / "control"). settings(baseSettings ++ Util.crossBuild: _*). settings( - name := "Control" + name := "Control", + crossScalaVersions := Seq(scala210, scala211) ) lazy val collectionProj = (project in utilPath / "collection"). settings(testedBaseSettings ++ Util.keywordsSettings ++ Util.crossBuild: _*). settings( - name := "Collections" + name := "Collections", + crossScalaVersions := Seq(scala210, scala211) ) lazy val applyMacroProj = (project in utilPath / "appmacro"). @@ -137,7 +135,8 @@ lazy val ioProj = (project in utilPath / "io"). settings(testedBaseSettings ++ Util.crossBuild: _*). settings( name := "IO", - libraryDependencies += { "org.scala-lang" % "scala-compiler" % scalaVersion.value % Test } + libraryDependencies += scalaCompiler.value % Test, + crossScalaVersions := Seq(scala210, scala211) ) // Utilities related to reflection, managing Scala versions, and custom class loaders @@ -155,7 +154,8 @@ lazy val completeProj = (project in utilPath / "complete"). settings(testedBaseSettings ++ Util.crossBuild: _*). settings( name := "Completion", - libraryDependencies += jline + libraryDependencies += jline, + crossScalaVersions := Seq(scala210, scala211) ) // logging @@ -517,3 +517,48 @@ def precompiled(scalav: String): Project = Project(id = normalize("Precompiled " // so we do not need to worry about cross-versioning testing dependencies sources in Test := Nil ) + +lazy val safeUnitTests = taskKey[Unit]("Known working tests (for both 2.10 and 2.11)") +lazy val safeProjects: ScopeFilter = ScopeFilter( + inProjects(launchProj, mainSettingsProj, mainProj, ivyProj, completeProj, + actionsProj, classpathProj, collectionProj, compileIncrementalProj, + logProj, runProj, stdTaskProj), + inConfigurations(Test) +) + +def customCommands: Seq[Setting[_]] = Seq( + commands += Command.command("setupBuildScala211") { state => + s"""set scalaVersion in ThisBuild := "$scala211" """ :: + state + }, + // This is invoked by Travis + commands += Command.command("checkBuildScala211") { state => + s"++ $scala211" :: + // First compile everything before attempting to test + "all compile test:compile" :: + // Now run known working tests. + safeUnitTests.key.label :: + state + }, + safeUnitTests := { + test.all(safeProjects).value + }, + commands += Command.command("release-sbt-local") { state => + "clean" :: + "so compile" :: + "so publishLocal" :: + "reload" :: + state + }, + commands += Command.command("release-sbt") { state => + // TODO - Any sort of validation + "clean" :: + "checkCredentials" :: + "conscript-configs" :: + "so compile" :: + "so publishSigned" :: + "publishLauncher" :: + "release-libs-211" :: + state + } +) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 03fc8a44c..887324c4f 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -2,6 +2,9 @@ import sbt._ import Keys._ object Dependencies { + lazy val scala210 = "2.10.4" + lazy val scala211 = "2.11.1" + lazy val jline = "jline" % "jline" % "2.11" lazy val ivy = "org.scala-sbt.ivy" % "ivy" % "2.3.0-sbt-fccfbd44c9f64523b61398a0155784dcbaeae28f" lazy val jsch = "com.jcraft" % "jsch" % "0.1.46" intransitive () @@ -11,6 +14,10 @@ object Dependencies { lazy val jawnJson4s = "org.spire-math" %% "json4s-support" % "0.6.0" lazy val scalaCompiler = Def.setting { "org.scala-lang" % "scala-compiler" % scalaVersion.value } lazy val testInterface = "org.scala-sbt" % "test-interface" % "1.0" + lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.11.4" + lazy val specs2 = "org.specs2" %% "specs2" % "2.3.11" + lazy val junit = "junit" % "junit" % "4.11" + private def scala211Module(name: String, moduleVersion: String) = Def.setting { scalaVersion.value match { diff --git a/project/NightlyPlugin.scala b/project/NightlyPlugin.scala new file mode 100644 index 000000000..bddc7cafc --- /dev/null +++ b/project/NightlyPlugin.scala @@ -0,0 +1,41 @@ +import sbt._ +import Keys._ +import Dependencies._ + +object NightlyPlugin extends AutoPlugin { + import autoImport._ + + override def trigger = allRequirements + override def requires = plugins.JvmPlugin + object autoImport { + lazy val nightly212 = SettingKey[Boolean]("nightly212") + lazy val includeTestDependencies = SettingKey[Boolean]("includeTestDependencies", "Doesn't declare test dependencies.") + + def testDependencies = libraryDependencies <++= includeTestDependencies { incl => + if (incl) Seq( + scalaCheck % Test, + specs2 % Test, + junit % Test + ) + else Seq() + } + } + + override def buildSettings: Seq[Setting[_]] = Seq( + nightly212 <<= scalaVersion(v => v.startsWith("2.12.")), + includeTestDependencies <<= nightly212(x => !x) + ) + + override def projectSettings: Seq[Setting[_]] = Seq( + crossVersion in update := { + scalaVersion.value match { + case sv if sv startsWith "2.8." => crossVersion.value + case sv if sv startsWith "2.9." => crossVersion.value + case sv if sv startsWith "2.10." => crossVersion.value + case sv if sv startsWith "2.11." => CrossVersion.full + case sv if sv startsWith "2.12." => CrossVersion.full + } + }, + resolvers += Resolver.typesafeIvyRepo("releases") + ) +} diff --git a/project/Util.scala b/project/Util.scala index 744a52f0f..6217cce8b 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -7,15 +7,9 @@ object Util { lazy val componentID = SettingKey[Option[String]]("component-id") lazy val scalaKeywords = TaskKey[Set[String]]("scala-keywords") lazy val generateKeywords = TaskKey[File]("generateKeywords") - lazy val nightly211 = SettingKey[Boolean]("nightly-211") - lazy val includeTestDependencies = SettingKey[Boolean]("includeTestDependencies", "Doesn't declare test dependencies.") def noPublishSettings: Seq[Setting[_]] = Seq(publish := {}) - def nightlySettings = Seq( - nightly211 <<= scalaVersion(v => v.startsWith("2.11.") || v.startsWith("2.12.")), - includeTestDependencies <<= nightly211(x => !x) - ) def crossBuild: Seq[Setting[_]] = Seq( crossPaths := (scalaBinaryVersion.value match { @@ -37,15 +31,6 @@ object Util { } ) - def testDependencies = libraryDependencies <++= includeTestDependencies { incl => - if (incl) Seq( - "org.scalacheck" %% "scalacheck" % "1.11.4" % "test", - "org.specs2" %% "specs2" % "2.3.11" % "test", - "junit" % "junit" % "4.11" % "test" - ) - else Seq() - } - def projectComponent = projectID <<= (projectID, componentID) { (pid, cid) => cid match { case Some(id) => pid extra ("e:component" -> id); case None => pid } } @@ -149,56 +134,6 @@ object %s { generateKeywords <<= (sourceManaged, scalaKeywords) map writeScalaKeywords, sourceGenerators <+= generateKeywords map (x => Seq(x)) )) - - def customCommands: Seq[Setting[_]] = Seq( - commands += Command.command("setupBuildScala211") { state => - """set scalaVersion in ThisBuild := "2.11.1" """ :: - "set Util.includeTestDependencies in ThisBuild := true" :: - state - }, - commands += Command.command("checkBuildScala211") { state => - "setupBuildScala211" :: - // First compile everything before attempting to test - "all compile test:compile" :: - // Now run known working tests. - "safeUnitTests" :: - state - }, - commands += Command.command("safeUnitTests") { state => - "all launcher/test main-settings/test main/test ivy/test logic/test completion/test actions/test classpath/test collections/test incremental-compiler/test logging/test run/test task-system/test" :: - state - }, - // TODO - To some extent these should take args to figure out what to do. - commands += Command.command("release-libs-211") { state => - "setupBuildScala211" :: - /// First test - agregateTaskHack("test") :: - // Note: You need the sbt-pgp plugin installed to release. - agregateTaskHack("publishSigned") :: - // Now restore the defaults. - "reload" :: state - }, - commands += Command.command("release-sbt-local") { state => - "publishLocal" :: - "setupBuildScala211" :: - agregateTaskHack("publishLocal") :: - "reload" :: - state - }, - commands += Command.command("release-sbt") { state => - // TODO - Any sort of validation - "checkCredentials" :: - "conscript-configs" :: - "publishSigned" :: - "publishLauncher" :: - "release-libs-211" :: - state - } - ) - // Aggregate task for 2.11 - def agregateTaskHack(task: String): String = - s"all control/$task collections/$task io/$task completion/$task" - } object Licensed { lazy val notice = SettingKey[File]("notice") diff --git a/project/p.sbt b/project/p.sbt index 723e694fb..5ea1b55b1 100644 --- a/project/p.sbt +++ b/project/p.sbt @@ -12,3 +12,5 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.1") addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0") addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0") + +addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.1")