From 6a3c9887c8ea05acea84b1c6285f5920940d0665 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 11 May 2019 22:19:38 -0400 Subject: [PATCH] Reduce concurrency of scalafmtCheck Ref https://github.com/scalameta/scalafmt/issues/1399 --- build.sbt | 4 ++-- project/FixScalafmtPlugin.scala | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 project/FixScalafmtPlugin.scala diff --git a/build.sbt b/build.sbt index bb6b63d8d8..5433cb5452 100644 --- a/build.sbt +++ b/build.sbt @@ -27,8 +27,8 @@ ThisBuild / version := { } } ThisBuild / licenses := List(("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0"))) -ThisBuild / scalafmtOnCompile := true -ThisBuild / Test / scalafmtOnCompile := true +ThisBuild / scalafmtOnCompile := !(Global / insideCI).value +ThisBuild / Test / scalafmtOnCompile := !(Global / insideCI).value def buildLevelSettings: Seq[Setting[_]] = Seq( // https://github.com/sbt/sbt-git/issues/109 diff --git a/project/FixScalafmtPlugin.scala b/project/FixScalafmtPlugin.scala new file mode 100644 index 0000000000..35291e473f --- /dev/null +++ b/project/FixScalafmtPlugin.scala @@ -0,0 +1,23 @@ +import sbt._ +import Keys._ +import org.scalafmt.sbt.ScalafmtPlugin +import ScalafmtPlugin.autoImport._ + +object FixScalafmtPlugin extends AutoPlugin { + override def requires = ScalafmtPlugin + override def trigger = allRequirements + + val ScalaFmtTag = ConcurrentRestrictions.Tag("scalafmt") + + override def globalSettings: Seq[Def.Setting[_]] = + Seq( + concurrentRestrictions += Tags.limit(ScalaFmtTag, 1) + ) + + override def projectSettings: Seq[Def.Setting[_]] = + Seq( + scalafmtCheckAll := (scalafmtCheckAll.tag(ScalaFmtTag)).value, + Compile / scalafmtCheck := ((Compile / scalafmtCheck).tag(ScalaFmtTag)).value, + Test / scalafmtCheck := ((Test / scalafmtCheck).tag(ScalaFmtTag)).value, + ) +}