From da4b005f0f45b2defbd9a74595debf8855331e74 Mon Sep 17 00:00:00 2001 From: "Ross A. Baker" Date: Wed, 21 Oct 2020 22:04:15 -0400 Subject: [PATCH] Support Dotty --- README.md | 2 +- build.sbt | 1 + .../org/http4s/sbt/Http4sOrgPlugin.scala | 14 +++++++---- .../scala/org/http4s/sbt/SilencerPlugin.scala | 23 +++++++++++-------- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 92e88da..00a3257 100644 --- a/README.md +++ b/README.md @@ -59,4 +59,4 @@ Enable with `enablePlugins(SilencerPlugin)` * Adds the [silencer](https://github.com/ghik/silencer) compiler plugin to suppress warnings. * Adds the supporting library to `CompileTime` and `Test` scopes, so it doesn't leave a trace in production. - +* Disabled automatically in Dotty diff --git a/build.sbt b/build.sbt index a7efed9..68d83e3 100644 --- a/build.sbt +++ b/build.sbt @@ -11,6 +11,7 @@ lazy val core = project .settings(commonSettings) .settings( name := "sbt-http4s-org", + addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.4"), addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.15"), addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.6.0"), addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1"), diff --git a/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala b/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala index be00fb0..ce3e3fd 100644 --- a/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala +++ b/core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala @@ -4,6 +4,7 @@ import sbt._ import sbt.Keys._ import com.typesafe.sbt.SbtGit.git +import dotty.tools.sbtplugin.DottyPlugin.autoImport._ import de.heikoseeberger.sbtheader.{AutomateHeaderPlugin, LicenseDetection, LicenseStyle} import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._ import java.lang.{Runtime => JRuntime} @@ -34,11 +35,14 @@ object Http4sOrgPlugin extends AutoPlugin { val scalaSettings: Seq[Setting[_]] = Seq( - scalacOptions ++= - Seq( - "-Ybackend-parallelism", - math.min(JRuntime.getRuntime.availableProcessors, 16).toString - ) + scalacOptions ++= { + if (isDotty.value) Seq.empty + else + Seq( + "-Ybackend-parallelism", + math.min(JRuntime.getRuntime.availableProcessors, 16).toString + ) + } ) val docSettings: Seq[Setting[_]] = diff --git a/core/src/main/scala/org/http4s/sbt/SilencerPlugin.scala b/core/src/main/scala/org/http4s/sbt/SilencerPlugin.scala index 8138bef..414fcce 100644 --- a/core/src/main/scala/org/http4s/sbt/SilencerPlugin.scala +++ b/core/src/main/scala/org/http4s/sbt/SilencerPlugin.scala @@ -3,8 +3,8 @@ package org.http4s.sbt import sbt._ import sbt.Keys._ +import dotty.tools.sbtplugin.DottyPlugin.autoImport._ import explicitdeps.ExplicitDepsPlugin.autoImport._ - import CompileTimePlugin.CompileTime object SilencerPlugin extends AutoPlugin { @@ -20,14 +20,19 @@ object SilencerPlugin extends AutoPlugin { override lazy val projectSettings: Seq[Setting[_]] = Seq( silencerVersion := "1.7.0", - libraryDependencies ++= Seq( - compilerPlugin( - ("com.github.ghik" % "silencer-plugin" % silencerVersion.value).cross(CrossVersion.full)), - ("com.github.ghik" % "silencer-lib" % silencerVersion.value % CompileTime) - .cross(CrossVersion.full), - ("com.github.ghik" % "silencer-lib" % silencerVersion.value % Test) - .cross(CrossVersion.full) - ), + libraryDependencies ++= { + if (isDotty.value) Seq.empty + else + Seq( + compilerPlugin( + ("com.github.ghik" % "silencer-plugin" % silencerVersion.value).cross( + CrossVersion.full)), + ("com.github.ghik" % "silencer-lib" % silencerVersion.value % CompileTime) + .cross(CrossVersion.full), + ("com.github.ghik" % "silencer-lib" % silencerVersion.value % Test) + .cross(CrossVersion.full) + ) + }, unusedCompileDependenciesFilter -= moduleFilter("com.github.ghik", name = "silencer-lib") ) }