diff --git a/build.sbt b/build.sbt index 85acd59312..71beeca1f3 100644 --- a/build.sbt +++ b/build.sbt @@ -101,12 +101,12 @@ lazy val root = (project in file(".")) ) lazy val zioHttp = (project in file("zio-http")) - .enablePlugins(ShadingPlugin) + .enablePlugins(Shading.plugins() : _*) .settings(stdSettings("zio-http")) .settings(publishSetting(true)) .settings(settingsWithHeaderLicense) .settings(meta) - .settings(Shading.shadingSettings(shadingEnabled)) + .settings(Shading.shadingSettings()) .settings( testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"), libraryDependencies ++= netty ++ Seq( @@ -153,10 +153,10 @@ lazy val zioHttpExample = (project in file("zio-http-example")) .dependsOn(zioHttp, zioHttpCli) lazy val zioHttpTestkit = (project in file("zio-http-testkit")) - .enablePlugins(ShadingPlugin) + .enablePlugins(Shading.plugins() : _*) .settings(stdSettings("zio-http-testkit")) .settings(publishSetting(true)) - .settings(Shading.shadingSettings(shadingEnabled)) + .settings(Shading.shadingSettings()) .settings( testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"), libraryDependencies ++= netty ++ Seq( diff --git a/project/BuildHelper.scala b/project/BuildHelper.scala index 6154e7803f..bc1e89a24b 100644 --- a/project/BuildHelper.scala +++ b/project/BuildHelper.scala @@ -105,11 +105,7 @@ object BuildHelper extends ScalaSettings { ) private def shadedSuffix = { - if (shadingEnabled) "-shaded" else "" - } - - def shadingEnabled = { - sys.props.get("publish.shaded").fold(false)(_.toBoolean) + if (Shading.shadingEnabled) "-shaded" else "" } def runSettings(className: String = "example.HelloWorld") = Seq( diff --git a/project/Shading.scala b/project/Shading.scala index 2b4941bfb1..af86cdcdb3 100644 --- a/project/Shading.scala +++ b/project/Shading.scala @@ -1,12 +1,20 @@ import Dependencies._ +import coursier.ShadingPlugin import coursier.ShadingPlugin.autoImport._ +import sbt.Plugins object Shading { - def shadingSettings(enabled: Boolean = true) = if(enabled) { + def shadingSettings() = if (shadingEnabled) { Seq( shadedModules ++= (netty :+ `netty-incubator`).map(_.module).toSet, shadingRules += ShadingRule.rename("io.netty.**", "zio.http.shaded.netty.@1"), validNamespaces += "zio", ) } else Nil + + def shadingEnabled = { + sys.props.get("publish.shaded").fold(false)(_.toBoolean) + } + + def plugins(): Seq[Plugins] = if(shadingEnabled) Seq(ShadingPlugin) else Nil }