Merge pull request #3184 from dwijnand/sbt-1-on-1

Upgrade the build to use sbt 1.0.0-M5
This commit is contained in:
Dale Wijnand 2017-05-11 10:31:21 +01:00 committed by GitHub
commit 0b2081bc3c
16 changed files with 54 additions and 29 deletions

View File

@ -16,7 +16,8 @@ matrix:
env: env:
matrix: matrix:
- SBT_CMD=";mimaReportBinaryIssues;test:compile;scalafmtCheck;safeUnitTests;otherUnitTests" - SBT_CMD=";test:compile;scalafmtCheck;safeUnitTests;otherUnitTests"
# - SBT_CMD="mimaReportBinaryIssues"
- SBT_CMD="scripted actions/*" - SBT_CMD="scripted actions/*"
- SBT_CMD="scripted apiinfo/* compiler-project/* ivy-deps-management/*" - SBT_CMD="scripted apiinfo/* compiler-project/* ivy-deps-management/*"
- SBT_CMD="scripted dependency-management/*1of4" - SBT_CMD="scripted dependency-management/*1of4"

View File

@ -44,16 +44,17 @@ def commonSettings: Seq[Setting[_]] =
concurrentRestrictions in Global += Util.testExclusiveRestriction, concurrentRestrictions in Global += Util.testExclusiveRestriction,
testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"), testOptions += Tests.Argument(TestFrameworks.ScalaCheck, "-w", "1"),
javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"), javacOptions in compile ++= Seq("-target", "6", "-source", "6", "-Xlint", "-Xlint:-serial"),
incOptions := incOptions.value.withNameHashing(true),
crossScalaVersions := Seq(baseScalaVersion), crossScalaVersions := Seq(baseScalaVersion),
bintrayPackage := (bintrayPackage in ThisBuild).value, bintrayPackage := (bintrayPackage in ThisBuild).value,
bintrayRepository := (bintrayRepository in ThisBuild).value, bintrayRepository := (bintrayRepository in ThisBuild).value,
publishArtifact in Test := false, publishArtifact in Test := false,
/*
mimaPreviousArtifacts := Set.empty, // Set(organization.value % moduleName.value % "1.0.0"), mimaPreviousArtifacts := Set.empty, // Set(organization.value % moduleName.value % "1.0.0"),
mimaBinaryIssueFilters ++= { mimaBinaryIssueFilters ++= {
import com.typesafe.tools.mima.core._, ProblemFilters._ import com.typesafe.tools.mima.core._, ProblemFilters._
Seq() Seq()
}, },
*/
fork in compile := true, fork in compile := true,
fork in run := true fork in run := true
) flatMap (_.settings) ) flatMap (_.settings)
@ -69,9 +70,9 @@ def testedBaseSettings: Seq[Setting[_]] =
baseSettings ++ testDependencies baseSettings ++ testDependencies
lazy val sbtRoot: Project = (project in file(".")) lazy val sbtRoot: Project = (project in file("."))
.enablePlugins(ScriptedPlugin, SiteScaladocPlugin, GhpagesPlugin) .enablePlugins(ScriptedPlugin) // , SiteScaladocPlugin, GhpagesPlugin)
.configs(Sxr.sxrConf) .configs(Sxr.sxrConf)
.aggregate(nonRoots: _*) .aggregateSeq(nonRoots)
.settings( .settings(
buildLevelSettings, buildLevelSettings,
minimalSettings, minimalSettings,
@ -294,7 +295,8 @@ lazy val sbtProj = (project in file("sbt"))
def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask { def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed val result = scriptedSource(dir => (s: State) => Scripted.scriptedParser(dir)).parsed
publishLocalBinAll.value // publishLocalBinAll.value // TODO: Restore scripted needing only binary jars.
publishAll.value
// These two projects need to be visible in a repo even if the default // These two projects need to be visible in a repo even if the default
// local repository is hidden, so we publish them to an alternate location and add // local repository is hidden, so we publish them to an alternate location and add
// that alternate repo to the running scripted test (in Scripted.scriptedpreScripted). // that alternate repo to the running scripted test (in Scripted.scriptedpreScripted).

View File

@ -1,8 +1,8 @@
import org.scalafmt.bootstrap.ScalafmtBootstrap import org.scalafmt.cli.Cli
import org.scalafmt.sbt.ScalafmtPlugin import org.scalafmt.sbt.ScalafmtPlugin
import sbt._ import sbt._
import sbt.Keys._ import sbt.Keys._
import sbt.inc.Analysis import sbt.internal.inc.Analysis
// Taken from https://github.com/akka/alpakka/blob/master/project/AutomateScalafmtPlugin.scala // Taken from https://github.com/akka/alpakka/blob/master/project/AutomateScalafmtPlugin.scala
object AutomateScalafmtPlugin extends AutoPlugin { object AutomateScalafmtPlugin extends AutoPlugin {
@ -18,7 +18,7 @@ object AutomateScalafmtPlugin extends AutoPlugin {
}, },
sourceDirectories.in(scalafmtInc) := Seq(scalaSource.value), sourceDirectories.in(scalafmtInc) := Seq(scalaSource.value),
scalafmtInc := { scalafmtInc := {
val cache = streams.value.cacheDirectory / "scalafmt" val cache = streams.value.cacheStoreFactory / "scalafmt"
val include = includeFilter.in(scalafmtInc).value val include = includeFilter.in(scalafmtInc).value
val exclude = excludeFilter.in(scalafmtInc).value val exclude = excludeFilter.in(scalafmtInc).value
val sources = val sources =
@ -39,14 +39,14 @@ object AutomateScalafmtPlugin extends AutoPlugin {
handler(files) handler(files)
files files
} }
FileFunction.cached(cache)(FilesInfo.hash, FilesInfo.exists)(update(handler, msg))( FileFunction.cached(cache, FilesInfo.hash, FilesInfo.exists)(update(handler, msg))(
sources sources
) )
} }
def formattingHandler(files: Set[File]) = def formattingHandler(files: Set[File]) =
if (files.nonEmpty) { if (files.nonEmpty) {
val filesArg = files.map(_.getAbsolutePath).mkString(",") val filesArg = files.map(_.getAbsolutePath).mkString(",")
ScalafmtBootstrap.main(List("--quiet", "-i", "-f", filesArg)) Cli.main(Array("--quiet", "-i", "-f", filesArg))
} }
format(formattingHandler, "Formatting") format(formattingHandler, "Formatting")
format(_ => (), "Reformatted") // Recalculate the cache format(_ => (), "Reformatted") // Recalculate the cache

View File

@ -1,12 +1,17 @@
import sbt._, Keys._ import sbt._, Keys._
/*
import StatusPlugin.autoImport._ import StatusPlugin.autoImport._
import com.typesafe.sbt.site.SitePlugin.autoImport._ import com.typesafe.sbt.site.SitePlugin.autoImport._
import com.typesafe.sbt.site.SiteScaladocPlugin.autoImport._ import com.typesafe.sbt.site.SiteScaladocPlugin.autoImport._
import com.typesafe.sbt.sbtghpages.GhpagesPlugin.autoImport._ import com.typesafe.sbt.sbtghpages.GhpagesPlugin.autoImport._
import com.typesafe.sbt.SbtGit, SbtGit.{ git, GitKeys } import com.typesafe.sbt.SbtGit, SbtGit.{ git, GitKeys }
import Sxr.{ sxr, sxrConf } import Sxr.{ sxr, sxrConf }
*/
object Docs { object Docs {
def settings: Seq[Setting[_]] = Nil
/*
val siteExcludes = Set(".buildinfo", "objects.inv") val siteExcludes = Set(".buildinfo", "objects.inv")
def siteInclude(f: File) = !siteExcludes.contains(f.getName) def siteInclude(f: File) = !siteExcludes.contains(f.getName)
@ -47,4 +52,5 @@ object Docs {
IO.copy(toCopy) IO.copy(toCopy)
repo repo
} }
*/
} }

View File

@ -17,12 +17,11 @@ object NightlyPlugin extends AutoPlugin {
import autoImport._ import autoImport._
override def buildSettings: Seq[Setting[_]] = Seq( override def buildSettings: Seq[Setting[_]] = Seq(
// Avoid 2.12.x nightlies
// Avoid 2.9.x precompiled // Avoid 2.9.x precompiled
// Avoid 2.8.x precompiled // Avoid 2.8.x precompiled
includeTestDependencies := { includeTestDependencies := {
val v = scalaVersion.value val v = scalaVersion.value
v.startsWith("2.10.") || v.startsWith("2.11.") v.startsWith("2.10.") || v.startsWith("2.11.") || v.startsWith("2.12.")
} }
) )

View File

@ -1,5 +1,7 @@
import sbt._, Keys._ import sbt._, Keys._
import sbt.internal.librarymanagement.PublishConfiguration
/** This local plugin provides ways of publishing just the binary jar. */ /** This local plugin provides ways of publishing just the binary jar. */
object PublishBinPlugin extends AutoPlugin { object PublishBinPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin override def requires = plugins.JvmPlugin

View File

@ -1,6 +1,6 @@
import sbt._ import sbt._
import Keys._ import Keys._
import com.typesafe.sbt.JavaVersionCheckPlugin.autoImport._ //import com.typesafe.sbt.JavaVersionCheckPlugin.autoImport._
import _root_.bintray.BintrayPlugin.autoImport._ import _root_.bintray.BintrayPlugin.autoImport._
import _root_.bintray.InternalBintrayKeys._ import _root_.bintray.InternalBintrayKeys._
@ -26,6 +26,6 @@ object Release {
) )
def javaVersionCheckSettings = Seq( def javaVersionCheckSettings = Seq(
javaVersionPrefix in javaVersionCheck := Some("1.8") //javaVersionPrefix in javaVersionCheck := Some("1.8")
) )
} }

View File

@ -1,3 +1,4 @@
import sbt.io.Path._
import sbt._ import sbt._
import Keys._ import Keys._
@ -41,7 +42,7 @@ object SbtLauncherPlugin extends AutoPlugin {
IO.unzip(jar, dir) IO.unzip(jar, dir)
IO.copy(overrides.map({ case (n, f) => (f, dir / n) }), overwrite = true) IO.copy(overrides.map({ case (n, f) => (f, dir / n) }), overwrite = true)
// TODO - is the ok for creating a jar? // TODO - is the ok for creating a jar?
IO.zip((dir.*** --- dir) pair relativeTo(dir), target) IO.zip((dir.allPaths --- dir) pair relativeTo(dir), target)
} }
target target
} }

View File

@ -1,6 +1,8 @@
import sbt._ import sbt._
import Keys._ import Keys._
import Def.Initialize import Def.Initialize
import sbt.internal.inc.ScalaInstance
import sbt.internal.inc.classpath
import scala.language.reflectiveCalls import scala.language.reflectiveCalls

View File

@ -1,3 +1,4 @@
import sbt.io.Path._
import sbt._ import sbt._
object SiteMap { object SiteMap {

View File

@ -2,6 +2,10 @@ import sbt._
import Keys._ import Keys._
import Scope.ThisScope import Scope.ThisScope
import sbt.librarymanagement.syntax._
import sbt.internal.inc.RawCompiler
object Sxr { object Sxr {
val sxrConf = config("sxr").hide val sxrConf = config("sxr").hide
val sxr = TaskKey[File]("sxr") val sxr = TaskKey[File]("sxr")
@ -31,7 +35,7 @@ object Sxr {
IO.delete(out) IO.delete(out)
IO.createDirectory(out) IO.createDirectory(out)
val comp = val comp =
new compiler.RawCompiler(scalaInstance.value, classpathOptions.value, streams.value.log) new RawCompiler(scalaInstance.value, classpathOptions.value, streams.value.log)
comp(in.toSeq.sorted, fullClasspath.value.files, out, scalacOptions.value) comp(in.toSeq.sorted, fullClasspath.value.files, out, scalacOptions.value)
Set(outputDir) Set(outputDir)
} }

View File

@ -1,3 +1,4 @@
import sbt.io.Path._
import sbt._ import sbt._
import Keys._ import Keys._

View File

@ -2,6 +2,8 @@ import scala.util.control.NonFatal
import sbt._ import sbt._
import Keys._ import Keys._
import sbt.internal.inc.Analysis
object Util { object Util {
val ExclusiveTest: Tags.Tag = Tags.Tag("exclusive-test") val ExclusiveTest: Tags.Tag = Tags.Tag("exclusive-test")
@ -86,17 +88,17 @@ object Util {
IO.createDirectory(out) IO.createDirectory(out)
val args = "xsbti.api" :: out.getAbsolutePath :: defs.map(_.getAbsolutePath).toList val args = "xsbti.api" :: out.getAbsolutePath :: defs.map(_.getAbsolutePath).toList
val mainClass = main getOrElse "No main class defined for datatype generator" val mainClass = main getOrElse "No main class defined for datatype generator"
toError(run.run(mainClass, cp.files, args, s.log)) run.run(mainClass, cp.files, args, s.log).failed foreach (e => sys error e.getMessage)
(out ** "*.java").get (out ** "*.java").get
} }
def lastCompilationTime(analysis: sbt.inc.Analysis): Long = { def lastCompilationTime(analysis: Analysis): Long = {
val lastCompilation = analysis.compilations.allCompilations.lastOption val lastCompilation = analysis.compilations.allCompilations.lastOption
lastCompilation.map(_.startTime) getOrElse 0L lastCompilation.map(_.startTime) getOrElse 0L
} }
def generateVersionFile(version: String, def generateVersionFile(version: String,
dir: File, dir: File,
s: TaskStreams, s: TaskStreams,
analysis: sbt.inc.Analysis): Seq[File] = { analysis: Analysis): Seq[File] = {
import java.util.{ Date, TimeZone } import java.util.{ Date, TimeZone }
val formatter = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss") val formatter = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss")
formatter.setTimeZone(TimeZone.getTimeZone("GMT")) formatter.setTimeZone(TimeZone.getTimeZone("GMT"))

View File

@ -1 +1 @@
sbt.version=0.13.13 sbt.version=1.0.0-M5

View File

@ -1,12 +1,11 @@
scalaVersion := "2.10.6" scalaVersion := "2.12.2"
scalacOptions ++= Seq("-feature", "-language:postfixOps") scalacOptions ++= Seq("-feature", "-language:postfixOps")
addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.5") // addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14")
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14") // addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.0") // addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.2") // addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0") addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.7.0-RC1")
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.6.8") // addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.2.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.2.0")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.4.0") addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.4.0")
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0-M4") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0-M4")

View File

@ -308,11 +308,16 @@ class ScriptedRunner {
tests: Array[String], tests: Array[String],
bootProperties: File, bootProperties: File,
launchOpts: Array[String], launchOpts: Array[String],
prescripted: java.util.List[File]): Unit = prescripted: java.util.List[File]): Unit = {
// Force Log4J to not use a thread context classloader otherwise it throws a CCE
sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true"
run(resourceBaseDirectory, bufferLog, tests, ConsoleLogger(), bootProperties, launchOpts, { run(resourceBaseDirectory, bufferLog, tests, ConsoleLogger(), bootProperties, launchOpts, {
f: File => f: File =>
prescripted.add(f); () prescripted.add(f); ()
}) //new FullLogger(Logger.xlog2Log(log))) }) //new FullLogger(Logger.xlog2Log(log)))
}
def run(resourceBaseDirectory: File, def run(resourceBaseDirectory: File,
bufferLog: Boolean, bufferLog: Boolean,