diff --git a/.scalafmt.conf b/.scalafmt.conf index 8a81e8505..1ede6f520 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = 2.0.0 +version = 2.2.1 maxColumn = 100 project.git = true project.excludeFilters = [ "\\Wsbt-test\\W", "\\Winput_sources\\W", "\\Wcontraband-scala\\W" ] diff --git a/.travis.yml b/.travis.yml index c6e8e3087..727e31e1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ env: # WHITESOURCE_PASSWORD= - secure: d3bu2KNwsVHwfhbGgO+gmRfDKBJhfICdCJFGWKf2w3Gv86AJZX9nuTYRxz0KtdvEHO5Xw8WTBZLPb2thSJqhw9OCm4J8TBAVqCP0ruUj4+aqBUFy4bVexQ6WKE6nWHs4JPzPk8c6uC1LG3hMuzlC8RGETXtL/n81Ef1u7NjyXjs= matrix: - - SBT_CMD=";mimaReportBinaryIssues ;scalafmtCheckAll ;headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal ;mainSettingsProj/test ;safeUnitTests ;otherUnitTests; doc" + - SBT_CMD="mimaReportBinaryIssues ;scalafmtCheckAll ; scalafmtSbtCheck; headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal ;mainSettingsProj/test ;safeUnitTests ;otherUnitTests; doc" - SBT_CMD="scripted actions/* apiinfo/* compiler-project/* ivy-deps-management/* reporter/* tests/* watch/* classloader-cache/* package/*" - SBT_CMD="scripted dependency-management/* plugins/* project-load/* java/* run/* nio/*" - SBT_CMD="repoOverrideTest:scripted dependency-management/*; scripted source-dependencies/* project/*" diff --git a/build.sbt b/build.sbt index 361c78838..1c20edbf4 100644 --- a/build.sbt +++ b/build.sbt @@ -67,7 +67,10 @@ def commonSettings: Seq[Setting[_]] = Def.settings( resolvers += Resolver.typesafeIvyRepo("releases").withName("typesafe-sbt-build-ivy-releases"), resolvers += Resolver.sonatypeRepo("snapshots"), resolvers += "bintray-sbt-maven-releases" at "https://dl.bintray.com/sbt/maven-releases/", - resolvers += Resolver.url("bintray-scala-hedgehog", url("https://dl.bintray.com/hedgehogqa/scala-hedgehog"))(Resolver.ivyStylePatterns), + resolvers += Resolver.url( + "bintray-scala-hedgehog", + url("https://dl.bintray.com/hedgehogqa/scala-hedgehog") + )(Resolver.ivyStylePatterns), addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.4" cross CrossVersion.binary), testFrameworks += TestFramework("hedgehog.sbt.Framework"), concurrentRestrictions in Global += Util.testExclusiveRestriction, @@ -242,7 +245,6 @@ val collectionProj = (project in file("internal") / "util-collection") // it's now abstract in KList and defined in both KCons & KNil. exclude[FinalMethodProblem]("sbt.internal.util.KNil.foldr"), exclude[DirectAbstractMethodProblem]("sbt.internal.util.KList.foldr"), - exclude[IncompatibleSignatureProblem]("sbt.internal.util.Init*.*"), exclude[IncompatibleSignatureProblem]("sbt.internal.util.Settings0.*"), exclude[IncompatibleSignatureProblem]("sbt.internal.util.EvaluateSettings#INode.*"), @@ -251,7 +253,9 @@ val collectionProj = (project in file("internal") / "util-collection") exclude[IncompatibleSignatureProblem]("sbt.internal.util.Settings.*"), exclude[IncompatibleSignatureProblem]("sbt.internal.util.EvaluateSettings#MixedNode.*"), exclude[IncompatibleSignatureProblem]("sbt.internal.util.EvaluateSettings#BindNode.this"), - exclude[IncompatibleSignatureProblem]("sbt.internal.util.EvaluateSettings#BindNode.dependsOn"), + exclude[IncompatibleSignatureProblem]( + "sbt.internal.util.EvaluateSettings#BindNode.dependsOn" + ), exclude[IncompatibleSignatureProblem]("sbt.internal.util.Types.some") ), ) @@ -736,7 +740,6 @@ lazy val mainProj = (project in file("main")) exclude[ReversedMissingMethodProblem]("sbt.internal.KeyIndex.*"), // internal exclude[IncompatibleMethTypeProblem]("sbt.internal.server.LanguageServerReporter.*"), - // Changed signature or removed private[sbt] methods exclude[DirectMissingMethodProblem]("sbt.Classpaths.unmanagedLibs0"), exclude[DirectMissingMethodProblem]("sbt.Defaults.allTestGroupsTask"), @@ -755,11 +758,14 @@ lazy val mainProj = (project in file("main")) exclude[IncompatibleSignatureProblem]("sbt.plugins.SbtPlugin.*Settings"), // Removed private internal classes exclude[MissingClassProblem]("sbt.internal.ReverseLookupClassLoaderHolder$BottomClassLoader"), - exclude[MissingClassProblem]("sbt.internal.ReverseLookupClassLoaderHolder$ReverseLookupClassLoader$ResourceLoader"), + exclude[MissingClassProblem]( + "sbt.internal.ReverseLookupClassLoaderHolder$ReverseLookupClassLoader$ResourceLoader" + ), exclude[MissingClassProblem]("sbt.internal.ReverseLookupClassLoaderHolder$ClassLoadingLock"), - exclude[MissingClassProblem]("sbt.internal.ReverseLookupClassLoaderHolder$ReverseLookupClassLoader"), + exclude[MissingClassProblem]( + "sbt.internal.ReverseLookupClassLoaderHolder$ReverseLookupClassLoader" + ), exclude[MissingClassProblem]("sbt.internal.LayeredClassLoaderImpl"), - // false positives exclude[DirectMissingMethodProblem]("sbt.plugins.IvyPlugin.requires"), exclude[DirectMissingMethodProblem]("sbt.plugins.JUnitXmlReportPlugin.requires"), @@ -769,17 +775,19 @@ lazy val mainProj = (project in file("main")) exclude[DirectMissingMethodProblem]("sbt.ResolvedClasspathDependency.apply"), exclude[DirectMissingMethodProblem]("sbt.ClasspathDependency.apply"), exclude[IncompatibleSignatureProblem]("sbt.plugins.SemanticdbPlugin.globalSettings"), - // File -> Source exclude[DirectMissingMethodProblem]("sbt.Defaults.cleanFilesTask"), exclude[IncompatibleSignatureProblem]("sbt.Defaults.resourceConfigPaths"), exclude[IncompatibleSignatureProblem]("sbt.Defaults.sourceConfigPaths"), exclude[IncompatibleSignatureProblem]("sbt.Defaults.configPaths"), exclude[IncompatibleSignatureProblem]("sbt.Defaults.paths"), - exclude[IncompatibleSignatureProblem]("sbt.Keys.csrPublications"), - exclude[IncompatibleSignatureProblem]("sbt.coursierint.CoursierArtifactsTasks.coursierPublicationsTask"), - exclude[IncompatibleSignatureProblem]("sbt.coursierint.CoursierArtifactsTasks.coursierPublicationsTask"), + exclude[IncompatibleSignatureProblem]( + "sbt.coursierint.CoursierArtifactsTasks.coursierPublicationsTask" + ), + exclude[IncompatibleSignatureProblem]( + "sbt.coursierint.CoursierArtifactsTasks.coursierPublicationsTask" + ), exclude[IncompatibleSignatureProblem]("sbt.coursierint.LMCoursier.coursierConfiguration"), exclude[IncompatibleSignatureProblem]("sbt.coursierint.LMCoursier.publicationsSetting"), exclude[IncompatibleSignatureProblem]("sbt.Project.inThisBuild"), @@ -790,7 +798,6 @@ lazy val mainProj = (project in file("main")) exclude[IncompatibleSignatureProblem]("sbt.ProjectExtra.inConfig"), exclude[IncompatibleSignatureProblem]("sbt.ProjectExtra.inTask"), exclude[IncompatibleSignatureProblem]("sbt.ProjectExtra.inScope"), - exclude[MissingTypesProblem]("sbt.internal.Load*"), exclude[IncompatibleSignatureProblem]("sbt.internal.Load*"), ) diff --git a/main/src/main/scala/sbt/Project.scala b/main/src/main/scala/sbt/Project.scala index 7fe9ea86a..7c4c1ce85 100755 --- a/main/src/main/scala/sbt/Project.scala +++ b/main/src/main/scala/sbt/Project.scala @@ -354,8 +354,9 @@ object Project extends ProjectExtra { validProjectID(id).foreach(errMsg => sys.error(s"Invalid project ID: $errMsg")) val plugins = Plugins.empty val origin = ProjectOrigin.GenericRoot - new ProjectDef(id, base, aggregate, Nil, Nil, Nil, plugins, Nil, origin) with Project - with GeneratedRootProject + new ProjectDef(id, base, aggregate, Nil, Nil, Nil, plugins, Nil, origin) + with Project + with GeneratedRootProject } /** Returns None if `id` is a valid Project ID or Some containing the parser error message if it is not.*/ diff --git a/main/src/main/scala/sbt/internal/SettingsGraph.scala b/main/src/main/scala/sbt/internal/SettingsGraph.scala index 317b5db77..ecf8266d1 100644 --- a/main/src/main/scala/sbt/internal/SettingsGraph.scala +++ b/main/src/main/scala/sbt/internal/SettingsGraph.scala @@ -148,7 +148,8 @@ private[sbt] object SettingsGraph { case _ => Some(Left(s)) } case _ => None - } else { + } + else { None } }.toSeq diff --git a/main/src/main/scala/sbt/internal/server/Definition.scala b/main/src/main/scala/sbt/internal/server/Definition.scala index b741f6feb..aad409b16 100644 --- a/main/src/main/scala/sbt/internal/server/Definition.scala +++ b/main/src/main/scala/sbt/internal/server/Definition.scala @@ -111,7 +111,8 @@ private[sbt] object Definition { case h :: _ if h.length < fragment.length => fragment :: Nil case h :: _ if h.length == fragment.length => fragment :: z case _ => z - } else z + } + else z } .headOption } diff --git a/project/Release.scala b/project/Release.scala index 74accb3a0..25cea8595 100644 --- a/project/Release.scala +++ b/project/Release.scala @@ -8,7 +8,8 @@ object Release { lazy val launcherRemotePath = SettingKey[String]("launcher-remote-path") lazy val deployLauncher = TaskKey[Unit]( "deploy-launcher", - "Upload the launcher to its traditional location for compatibility with existing scripts.") + "Upload the launcher to its traditional location for compatibility with existing scripts." + ) def launcherSettings(launcher: TaskKey[File]): Seq[Setting[_]] = Seq( launcherRemotePath := { @@ -17,11 +18,13 @@ object Release { }, deployLauncher := { val repo = bintrayRepo.value - repo.upload(bintrayPackage.value, - version.value, - launcherRemotePath.value, - launcher.value, - sLog.value) + repo.upload( + bintrayPackage.value, + version.value, + launcherRemotePath.value, + launcher.value, + sLog.value + ) } ) diff --git a/project/SbtLauncherPlugin.scala b/project/SbtLauncherPlugin.scala index 7d95ed9ee..0c24d2de5 100644 --- a/project/SbtLauncherPlugin.scala +++ b/project/SbtLauncherPlugin.scala @@ -45,8 +45,7 @@ object SbtLauncherPlugin extends AutoPlugin { // TODO - is the ok for creating a jar? val rebase: File => Seq[(File, String)] = { val path = dir.toPath - f => - if (f != dir) f -> path.relativize(f.toPath).toString :: Nil else Nil + f => if (f != dir) f -> path.relativize(f.toPath).toString :: Nil else Nil } IO.zip(dir.allPaths.get().flatMap(rebase), target) } diff --git a/project/StatusPlugin.scala b/project/StatusPlugin.scala index 6edd9cc5e..d2c0d2a6f 100644 --- a/project/StatusPlugin.scala +++ b/project/StatusPlugin.scala @@ -31,10 +31,12 @@ object StatusPlugin extends AutoPlugin { val status = extracted.get(publishStatus) // Set new version AND lock down the publishStatus to what it was, as // our release regexes no longer support ivy data format, due to other issues. - extracted.appendWithSession((version in ThisBuild ~= stamp) :: - (publishStatus in ThisBuild := status) :: - Nil, - state) + extracted.appendWithSession( + (version in ThisBuild ~= stamp) :: + (publishStatus in ThisBuild := status) :: + Nil, + state + ) } def stamp(v: String): String = { val Snapshot = "-SNAPSHOT" diff --git a/project/Transform.scala b/project/Transform.scala index e6d61676d..fde66b01c 100644 --- a/project/Transform.scala +++ b/project/Transform.scala @@ -38,11 +38,12 @@ object Transform { def get(key: String) = props.getOrElse(key, sys.error(s"No value defined for key '$key'")) val Property = """\$\{\{([\w.-]+)\}\}""".r val catcher = scala.util.control.Exception.catching(classOf[java.io.IOException]) - rs.map { case (in, out) => - val newString = Property.replaceAllIn(IO.read(in), mtch => get(mtch.group(1))) - if (Some(newString) != catcher.opt(IO.read(out))) - IO.write(out, newString) - out + rs.map { + case (in, out) => + val newString = Property.replaceAllIn(IO.read(in), mtch => get(mtch.group(1))) + if (Some(newString) != catcher.opt(IO.read(out))) + IO.write(out, newString) + out } }.taskValue, ) diff --git a/project/Util.scala b/project/Util.scala index 09714ca15..94d5ec0a1 100644 --- a/project/Util.scala +++ b/project/Util.scala @@ -44,24 +44,28 @@ object Util { lazy val apiDefinitions = TaskKey[Seq[File]]("api-definitions") - def generateAPICached(defs: Seq[File], - cp: Classpath, - out: File, - main: Option[String], - run: ScalaRun, - s: TaskStreams): Seq[File] = { + def generateAPICached( + defs: Seq[File], + cp: Classpath, + out: File, + main: Option[String], + run: ScalaRun, + s: TaskStreams + ): Seq[File] = { def gen() = generateAPI(defs, cp, out, main, run, s) val f = FileFunction.cached(s.cacheDirectory / "gen-api", FilesInfo.hash) { _ => gen().toSet } // TODO: check if output directory changed f(defs.toSet).toSeq } - def generateAPI(defs: Seq[File], - cp: Classpath, - out: File, - main: Option[String], - run: ScalaRun, - s: TaskStreams): Seq[File] = { + def generateAPI( + defs: Seq[File], + cp: Classpath, + out: File, + main: Option[String], + run: ScalaRun, + s: TaskStreams + ): Seq[File] = { IO.delete(out) IO.createDirectory(out) val args = "xsbti.api" :: out.getAbsolutePath :: defs.map(_.getAbsolutePath).toList @@ -73,10 +77,12 @@ object Util { val lastCompilation = analysis.compilations.allCompilations.lastOption lastCompilation.map(_.getStartTime) getOrElse 0L } - def generateVersionFile(version: String, - dir: File, - s: TaskStreams, - analysis: Analysis): Seq[File] = { + def generateVersionFile( + version: String, + dir: File, + s: TaskStreams, + analysis: Analysis + ): Seq[File] = { import java.util.{ Date, TimeZone } val formatter = new java.text.SimpleDateFormat("yyyyMMdd'T'HHmmss") formatter.setTimeZone(TimeZone.getTimeZone("GMT")) @@ -105,8 +111,7 @@ object Util { def cleanPom(pomNode: scala.xml.Node) = { import scala.xml._ def cleanNodes(nodes: Seq[Node]): Seq[Node] = nodes flatMap { - case elem @ Elem(_, "dependency", _, _, _*) - if excludePomDependency(elem) => + case elem @ Elem(_, "dependency", _, _, _*) if excludePomDependency(elem) => NodeSeq.Empty case Elem(_, "classifier", _, _, _*) => NodeSeq.Empty @@ -178,14 +183,18 @@ object Licensed { def settings: Seq[Setting[_]] = Seq( notice := (baseDirectory.value / "NOTICE"), unmanagedResources in Compile ++= notice.value +: extractLicenses.value, - extractLicenses := extractLicenses0((baseDirectory in ThisBuild).value, - notice.value, - streams.value) + extractLicenses := extractLicenses0( + (baseDirectory in ThisBuild).value, + notice.value, + streams.value + ) ) def extractLicenses0(base: File, note: File, s: TaskStreams): Seq[File] = if (!note.exists) Nil else - try { seePaths(base, IO.read(note)) } catch { + try { + seePaths(base, IO.read(note)) + } catch { case NonFatal(_) => s.log.warn("Could not read NOTICE"); Nil } } diff --git a/project/plugins.sbt b/project/plugins.sbt index d07487ba2..6bcc67599 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ scalacOptions ++= Seq("-feature", "-language:postfixOps", "-Ywarn-unused:_,-impo addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0") addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.5") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.2") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.2.1") addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.4.1") addSbtPlugin("de.heikoseeberger" % "sbt-header" % "3.0.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") diff --git a/protocol/src/main/scala/sbt/protocol/Serialization.scala b/protocol/src/main/scala/sbt/protocol/Serialization.scala index bd2e97ad3..75ef805ca 100644 --- a/protocol/src/main/scala/sbt/protocol/Serialization.scala +++ b/protocol/src/main/scala/sbt/protocol/Serialization.scala @@ -176,7 +176,8 @@ object Serialization { Converter.fromJson[JsonRpcRequestMessage](json) match { case Success(request) => Right(request) case Failure(e) => Left(s"Conversion error: ${e.getMessage}") - } else + } + else Converter.fromJson[JsonRpcNotificationMessage](json) match { case Success(notification) => Right(notification) case Failure(e) => Left(s"Conversion error: ${e.getMessage}") diff --git a/scripted-sbt-redux/src/main/scala/sbt/scriptedtest/ScriptedTests.scala b/scripted-sbt-redux/src/main/scala/sbt/scriptedtest/ScriptedTests.scala index fd8290c80..c07d5263a 100644 --- a/scripted-sbt-redux/src/main/scala/sbt/scriptedtest/ScriptedTests.scala +++ b/scripted-sbt-redux/src/main/scala/sbt/scriptedtest/ScriptedTests.scala @@ -179,7 +179,8 @@ final class ScriptedTests( case ("nio", "make-clone") => true // uses gcc which isn't set up on all systems case _ => false } - } else _ => false + } + else _ => false private def determineRemoteSbtCreatorKind(testName: (String, String)): RemoteSbtCreatorKind = { import RemoteSbtCreatorKind._ val (group, name) = testName