From bcc74a962eb66d4c551a091b65e4f8db233addb0 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 13 Jun 2017 00:10:21 -0400 Subject: [PATCH 1/2] bump to using sbt 1.0.0-M6 We are missing the plugin for Scalafmt but I think we need to use beta2 ourselves. --- .travis.yml | 2 +- project/ScalafmtPlugin.scala | 4 ++++ project/Sxr.scala | 13 +++++++++---- project/Util.scala | 2 +- project/build.properties | 2 +- project/plugins.sbt | 5 +++-- 6 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 project/ScalafmtPlugin.scala diff --git a/.travis.yml b/.travis.yml index feb7bebb2..a9bf28edc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: env: matrix: - - SBT_CMD=";test:compile;scalafmt::test;test:scalafmt::test;mainSettingsProj/test;safeUnitTests;otherUnitTests" + - SBT_CMD=";test:compile;mainSettingsProj/test;safeUnitTests;otherUnitTests" # - SBT_CMD="mimaReportBinaryIssues" - SBT_CMD="scripted actions/*" - SBT_CMD="scripted apiinfo/* compiler-project/* ivy-deps-management/*" diff --git a/project/ScalafmtPlugin.scala b/project/ScalafmtPlugin.scala new file mode 100644 index 000000000..1ab0ae778 --- /dev/null +++ b/project/ScalafmtPlugin.scala @@ -0,0 +1,4 @@ +import sbt._ + +// This is a placeholder so we don't have to change build.sbt. +object ScalafmtPlugin extends AutoPlugin {} diff --git a/project/Sxr.scala b/project/Sxr.scala index 32ae16e0c..e96aaad21 100644 --- a/project/Sxr.scala +++ b/project/Sxr.scala @@ -26,17 +26,22 @@ object Sxr { target := target.in(taskGlobal).value / "browse", sxr in taskGlobal := sxrTask.value ) - def taskGlobal = ThisScope.copy(task = Global) + def taskGlobal = ThisScope.copy(task = Zero) def sxrTask = Def task { val out = target.value val outputDir = out.getParentFile / (out.getName + ".sxr") + val log = streams.value.log + val si = scalaInstance.value + val cp = fullClasspath.value + val so = scalacOptions.value + val co = classpathOptions.value val f = FileFunction.cached(streams.value.cacheDirectory / "sxr", FilesInfo.hash) { in => - streams.value.log.info("Generating sxr output in " + outputDir.getAbsolutePath + "...") + log.info("Generating sxr output in " + outputDir.getAbsolutePath + "...") IO.delete(out) IO.createDirectory(out) val comp = - new RawCompiler(scalaInstance.value, classpathOptions.value, streams.value.log) - comp(in.toSeq.sorted, fullClasspath.value.files, out, scalacOptions.value) + new RawCompiler(si, co, log) + comp(in.toSeq.sorted, cp.files, out, so) Set(outputDir) } f(sources.value.toSet) diff --git a/project/Util.scala b/project/Util.scala index 5f8d13bd1..bfb02bd2b 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -93,7 +93,7 @@ object Util { } def lastCompilationTime(analysis: Analysis): Long = { val lastCompilation = analysis.compilations.allCompilations.lastOption - lastCompilation.map(_.startTime) getOrElse 0L + lastCompilation.map(_.getStartTime) getOrElse 0L } def generateVersionFile(version: String, dir: File, diff --git a/project/build.properties b/project/build.properties index 4a8f6a6c4..cd66fd542 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.0.0-M5 +sbt.version=1.0.0-M6 diff --git a/project/plugins.sbt b/project/plugins.sbt index b6eb790fe..d97012445 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,9 +5,10 @@ scalacOptions ++= Seq("-feature", "-language:postfixOps") // addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.0") // addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.2") // addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0") -//addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.7.0-RC1") -addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "0.3") // addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.2.0") addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.4.0") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0-M5") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1") + +// hopefully this comes back soon. +// addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "0.3") From 04f2a04fa4e2e8a62d850f64300f6c40ee7d246a Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 16 Jun 2017 16:11:33 -0400 Subject: [PATCH 2/2] sbt-scalafmt 1.3 --- .travis.yml | 2 +- build.sbt | 25 ++++++++----------------- project/ScalafmtPlugin.scala | 4 ---- project/plugins.sbt | 4 +--- 4 files changed, 10 insertions(+), 25 deletions(-) delete mode 100644 project/ScalafmtPlugin.scala diff --git a/.travis.yml b/.travis.yml index a9bf28edc..feb7bebb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: env: matrix: - - SBT_CMD=";test:compile;mainSettingsProj/test;safeUnitTests;otherUnitTests" + - SBT_CMD=";test:compile;scalafmt::test;test:scalafmt::test;mainSettingsProj/test;safeUnitTests;otherUnitTests" # - SBT_CMD="mimaReportBinaryIssues" - SBT_CMD="scripted actions/*" - SBT_CMD="scripted apiinfo/* compiler-project/* ivy-deps-management/*" diff --git a/build.sbt b/build.sbt index acc8b4260..8bf3f05d7 100644 --- a/build.sbt +++ b/build.sbt @@ -31,7 +31,10 @@ def buildLevelSettings: Seq[Setting[_]] = ), homepage := Some(url("https://github.com/sbt/sbt")), scmInfo := Some(ScmInfo(url("https://github.com/sbt/sbt"), "git@github.com:sbt/sbt.git")), - resolvers += Resolver.mavenLocal + resolvers += Resolver.mavenLocal, + scalafmtOnCompile := true, + // scalafmtVersion 1.0.0-RC3 has regression + scalafmtVersion := "0.6.8" )) def commonSettings: Seq[Setting[_]] = @@ -71,7 +74,6 @@ def testedBaseSettings: Seq[Setting[_]] = lazy val sbtRoot: Project = (project in file(".")) .enablePlugins(ScriptedPlugin) // , SiteScaladocPlugin, GhpagesPlugin) - .enablePlugins(ScalafmtPlugin) .configs(Sxr.sxrConf) .aggregateSeq(nonRoots) .settings( @@ -109,7 +111,6 @@ lazy val bundledLauncherProj = Release.launcherSettings(sbtLaunchJar) ) .enablePlugins(SbtLauncherPlugin) - .enablePlugins(ScalafmtPlugin) .settings( name := "sbt-launch", moduleName := "sbt-launch", @@ -128,7 +129,6 @@ lazy val bundledLauncherProj = // Runner for uniform test interface lazy val testingProj = (project in file("testing")) .enablePlugins(ContrabandPlugin, JsonCodecPlugin) - .enablePlugins(ScalafmtPlugin) .dependsOn(testAgentProj) .settings( baseSettings, @@ -143,7 +143,6 @@ lazy val testingProj = (project in file("testing")) // Testing agent for running tests in a separate process. lazy val testAgentProj = (project in file("testing") / "agent") - .enablePlugins(ScalafmtPlugin) .settings( minimalSettings, crossScalaVersions := Seq(baseScalaVersion), @@ -155,7 +154,6 @@ lazy val testAgentProj = (project in file("testing") / "agent") // Basic task engine lazy val taskProj = (project in file("tasks")) - .enablePlugins(ScalafmtPlugin) .settings( testedBaseSettings, name := "Tasks" @@ -164,7 +162,6 @@ lazy val taskProj = (project in file("tasks")) // Standard task system. This provides map, flatMap, join, and more on top of the basic task model. lazy val stdTaskProj = (project in file("tasks-standard")) - .enablePlugins(ScalafmtPlugin) .dependsOn(taskProj % "compile;test->test") .settings( testedBaseSettings, @@ -175,7 +172,7 @@ lazy val stdTaskProj = (project in file("tasks-standard")) // Embedded Scala code runner lazy val runProj = (project in file("run")) - .enablePlugins(ContrabandPlugin, ScalafmtPlugin) + .enablePlugins(ContrabandPlugin) .settings( testedBaseSettings, name := "Run", @@ -186,7 +183,6 @@ lazy val runProj = (project in file("run")) .configure(addSbtIO, addSbtUtilLogging, addSbtCompilerClasspath) lazy val scriptedSbtProj = (project in scriptedPath / "sbt") - .enablePlugins(ScalafmtPlugin) .dependsOn(commandProj) .settings( baseSettings, @@ -196,7 +192,6 @@ lazy val scriptedSbtProj = (project in scriptedPath / "sbt") .configure(addSbtIO, addSbtUtilLogging, addSbtCompilerInterface, addSbtUtilScripted) lazy val scriptedPluginProj = (project in scriptedPath / "plugin") - .enablePlugins(ScalafmtPlugin) .dependsOn(sbtProj) .settings( baseSettings, @@ -206,7 +201,6 @@ lazy val scriptedPluginProj = (project in scriptedPath / "plugin") // Implementation and support code for defining actions. lazy val actionsProj = (project in file("main-actions")) - .enablePlugins(ScalafmtPlugin) .dependsOn(runProj, stdTaskProj, taskProj, testingProj) .settings( testedBaseSettings, @@ -228,7 +222,7 @@ lazy val actionsProj = (project in file("main-actions")) ) lazy val protocolProj = (project in file("protocol")) - .enablePlugins(ContrabandPlugin, JsonCodecPlugin, ScalafmtPlugin) + .enablePlugins(ContrabandPlugin, JsonCodecPlugin) .settings( testedBaseSettings, name := "Protocol", @@ -242,7 +236,7 @@ lazy val protocolProj = (project in file("protocol")) // General command support and core commands not specific to a build system lazy val commandProj = (project in file("main-command")) - .enablePlugins(ContrabandPlugin, JsonCodecPlugin, ScalafmtPlugin) + .enablePlugins(ContrabandPlugin, JsonCodecPlugin) .dependsOn(protocolProj) .settings( testedBaseSettings, @@ -263,7 +257,6 @@ lazy val commandProj = (project in file("main-command")) // The core macro project defines the main logic of the DSL, abstracted // away from several sbt implementators (tasks, settings, et cetera). lazy val coreMacrosProj = (project in file("core-macros")) - .enablePlugins(ScalafmtPlugin) .settings( commonSettings, name := "Core Macros", @@ -293,7 +286,6 @@ lazy val generateToolboxClasspath = Def.task { // Fixes scope=Scope for Setting (core defined in collectionProj) to define the settings system used in build definitions lazy val mainSettingsProj = (project in file("main-settings")) - .enablePlugins(ScalafmtPlugin) .dependsOn(commandProj, stdTaskProj, coreMacrosProj) .settings( testedBaseSettings, @@ -313,7 +305,7 @@ lazy val mainSettingsProj = (project in file("main-settings")) // The main integration project for sbt. It brings all of the projects together, configures them, and provides for overriding conventions. lazy val mainProj = (project in file("main")) - .enablePlugins(ContrabandPlugin, ScalafmtPlugin) + .enablePlugins(ContrabandPlugin) .dependsOn(actionsProj, mainSettingsProj, runProj, commandProj) .settings( testedBaseSettings, @@ -334,7 +326,6 @@ lazy val mainProj = (project in file("main")) // technically, we need a dependency on all of mainProj's dependencies, but we don't do that since this is strictly an integration project // with the sole purpose of providing certain identifiers without qualification (with a package object) lazy val sbtProj = (project in file("sbt")) - .enablePlugins(ScalafmtPlugin) .dependsOn(mainProj, scriptedSbtProj % "test->test") .settings( baseSettings, diff --git a/project/ScalafmtPlugin.scala b/project/ScalafmtPlugin.scala deleted file mode 100644 index 1ab0ae778..000000000 --- a/project/ScalafmtPlugin.scala +++ /dev/null @@ -1,4 +0,0 @@ -import sbt._ - -// This is a placeholder so we don't have to change build.sbt. -object ScalafmtPlugin extends AutoPlugin {} diff --git a/project/plugins.sbt b/project/plugins.sbt index d97012445..bb94d09a1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,6 +9,4 @@ scalacOptions ++= Seq("-feature", "-language:postfixOps") addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.4.0") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.3.0-M5") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0-M1") - -// hopefully this comes back soon. -// addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "0.3") +addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.3")