diff --git a/build.sc b/build.sc index 3fa403b58..d661047b1 100644 --- a/build.sc +++ b/build.sc @@ -144,10 +144,28 @@ class ScalaKernelApi(val crossScalaVersion: String) extends AlmondModule with De scala.`jupyter-api`() ) def ivyDeps = Agg( - Deps.ammoniteCompiler(crossScalaVersion), - Deps.ammoniteReplApi(crossScalaVersion), + Deps.ammoniteCompiler(crossScalaVersion) + .exclude(("org.slf4j", "slf4j-api")), + Deps.ammoniteReplApi(crossScalaVersion) + .exclude(("org.slf4j", "slf4j-api")), Deps.jvmRepr ) + + def resolvedIvyDeps = T { + // Ensure we don't depend on slf4j-api + // As no logger implem would be loaded alongside it by default, slf4j would fail to initialize, + // complain in stderr, and default to NOP logging. + val value = super.resolvedIvyDeps() + val jarNames = value + .map(_.path.last) + .filter(_.endsWith(".jar")) + .map(_.stripSuffix(".jar")) + val slf4jJars = jarNames.filter(_.startsWith("slf4j-")) + if (slf4jJars.nonEmpty) + sys.error(s"Found slf4j JARs: ${slf4jJars.mkString(", ")}") + value + } + def propertyFilePath = "almond/almond.properties" def propertyExtra = Seq( "default-scalafmt-version" -> Deps.scalafmtDynamic.dep.version, @@ -174,8 +192,14 @@ class ScalaInterpreter(val crossScalaVersion: String) extends AlmondModule with ) def ivyDeps = T { val metabrowse = - if (crossScalaVersion.startsWith("2.")) Agg(Deps.metabrowseServer) - else Agg.empty + if (crossScalaVersion.startsWith("2.")) + Agg( + Deps.metabrowseServer + // don't let metabrowse bump our slf4j version (switching to v2 can be quite sensitive when Spark is involved) + .exclude(("org.slf4j", "slf4j-api")) + ) + else + Agg.empty metabrowse ++ Agg( Deps.coursier.withDottyCompat(crossScalaVersion), Deps.coursierApi, @@ -245,6 +269,27 @@ class ScalaKernel(val crossScalaVersion: String) extends AlmondModule with Exter ) } + def resolvedIvyDeps = T { + // Ensure we stay on slf4j 1.x + // Kind of unnecessary now that scala-kernel-api doesn't bring slf4j-api any more, + // but keeping that just in caseā€¦ + val value = super.resolvedIvyDeps() + val jarNames = value + .map(_.path.last) + .filter(_.endsWith(".jar")) + .map(_.stripSuffix(".jar")) + val slf4jJars = jarNames.filter(_.startsWith("slf4j-")) + assert(slf4jJars.nonEmpty, "No slf4j JARs found") + val wrongSlf4jVersionJars = slf4jJars.filter { name => + val version = name.split('-').dropWhile(_.head.isLetter).mkString("-") + !version.startsWith("1.") + } + if (wrongSlf4jVersionJars.nonEmpty) + sys.error(s"Found some slf4j non-1.x JARs: ${wrongSlf4jVersionJars.mkString(", ")}") + + value + } + def runClasspath = super.runClasspath() ++ transitiveSources() ++ diff --git a/project/deps.sc b/project/deps.sc index 591f07e9b..731686baa 100644 --- a/project/deps.sc +++ b/project/deps.sc @@ -46,7 +46,7 @@ object Deps { def classPathUtil = ivy"io.get-coursier::class-path-util:0.1.2" def collectionCompat = ivy"org.scala-lang.modules::scala-collection-compat:2.9.0" def coursier = ivy"io.get-coursier::coursier:2.1.3" - def coursierApi = ivy"io.get-coursier:interface:1.0.15" + def coursierApi = ivy"io.get-coursier:interface:1.0.16" def expecty = ivy"com.eed3si9n.expecty::expecty:0.16.0" def fs2 = ivy"co.fs2::fs2-core:2.5.11" def jansi = ivy"org.fusesource.jansi:jansi:2.4.0" @@ -66,7 +66,7 @@ object Deps { def scalaReflect(sv: String) = ivy"org.scala-lang:scala-reflect:$sv" def scalaRx = ivy"com.lihaoyi::scalarx:0.4.3" def scalatags = ivy"com.lihaoyi::scalatags:0.12.0" - def slf4jNop = ivy"org.slf4j:slf4j-nop:2.0.7" + def slf4jNop = ivy"org.slf4j:slf4j-nop:1.7.36" def utest = ivy"com.lihaoyi::utest:0.8.1" }