Skip to content

Commit

Permalink
Ensure scala-kernel-api doesn't bring slf4j-api
Browse files Browse the repository at this point in the history
As no logger implem would exist alongside by default, slf4j would
fail to initialize, complain loudly to stderr, and default to
NOP logging
  • Loading branch information
alexarchambault committed May 9, 2023
1 parent ae7c542 commit 392baa0
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -253,6 +271,8 @@ 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)
Expand Down

0 comments on commit 392baa0

Please sign in to comment.