Skip to content

Silence "differs from Scala binary version" warning in SBT build #100

Closed
@retronym

Description

@retronym
⚡ sbt dist/mkPack
[info] Loading global plugins from /Users/jason/.sbt/0.13/plugins
[info] Loading project definition from /Users/jason/code/scala2/project
[info] *** Welcome to the sbt build definition for Scala! ***
[info] This build definition has an EXPERIMENTAL status. If you are not
[info] interested in testing or working on the build itself, please use
[info] the Ant build definition for now. Check README.md for more information.
[warn] Binary version (2.12.0-SNAPSHOT) for dependency org.scala-lang#scala-library;2.12.0-SNAPSHOT
[warn]  in org.scala-lang#scala-reflect;2.12.0-SNAPSHOT differs from Scala binary version in project (2.12.0-3ecc141-nightly).
[warn] Binary version (2.12.0-SNAPSHOT) for dependency org.scala-lang#scala-library;2.12.0-SNAPSHOT
[warn]  in org.scala-lang#scala-compiler;2.12.0-SNAPSHOT differs from Scala binary version in project (2.12.0-3ecc141-nightly).
[warn] Binary version (2.12.0-SNAPSHOT) for dependency org.scala-lang#scala-reflect;2.12.0-SNAPSHOT
[warn]  in org.scala-lang#scala-compiler;2.12.0-SNAPSHOT differs from Scala binary version in project (2.12.0-3ecc141-nightly).

Related:

I can't figure out a clean way to disable the warning at the source (the code that emits it doesn't honour the conflictWarning setting.)

I was able to suppress the output by installing a custom logger:

diff --git a/build.sbt b/build.sbt
index 4600f46..60957d8 100644
--- a/build.sbt
+++ b/build.sbt
@@ -206,7 +206,9 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings +

   // Don't log process output (e.g. of forked `compiler/runMain ...Main`), just pass it
   // directly to stdout
-  outputStrategy in run := Some(StdoutOutput)
+  outputStrategy in run := Some(StdoutOutput),
+
+  quietIvy
 )

 /** Extra post-processing for the published POM files. These are needed to create POMs that
@@ -799,3 +801,28 @@ commands ++= {
 }

 addCommandAlias("scalap",   "scalap/compile:runMain              scala.tools.scalap.Main -usejavacp")
+
+def quietIvy = ivyConfiguration := {
+  ivyConfiguration.value match {
+    case c: InlineIvyConfiguration =>
+      val delegate = c.log
+      val logger = new Logger {
+        override def trace(t: => Throwable): Unit = delegate.trace(t)
+        override def log(level: sbt.Level.Value, message: => String): Unit = {
+          level match {
+            case sbt.Level.Warn =>
+              val message0 = message
+              val newLevel = if (message.contains("differs from Scala binary version in project"))
+                delegate.log(sbt.Level.Debug, message)
+              else
+                delegate.log(level, message)
+            case _ => delegate.log(level, message)
+          }
+        }
+        override def success(message: => String): Unit = delegate.success(message)
+      }
+      new InlineIvyConfiguration(c.paths, c.resolvers, c.otherResolvers, c.moduleConfigurations, c.localOnly, c.lock, c.checksums, c.resolutionCacheDir, c.updateOptions, logger)
+    case x => x
+  }
+}
+

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions