Skip to content

Commit e40d4bc

Browse files
retronymadriaanm
authored andcommitted
Eliminate major sources of daily noise in SBT build.
- Intercept incorrect "binary conflict" warning issued by SBT. Fixes scala/scala-dev#100 - Add a simple way to disable use of JarJar during developer builds, as a workaround for scala/scala-dev#146. I've submitted a PR upstream to fix the root problem with parameter names: pantsbuild/jarjar#18 - Disable info level logging for dependency resolve/download.
1 parent 06cf96a commit e40d4bc

File tree

2 files changed

+64
-20
lines changed

2 files changed

+64
-20
lines changed

build.sbt

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ globalVersionSettings
112112
baseVersion in Global := "2.12.0"
113113
baseVersionSuffix in Global := "SNAPSHOT"
114114

115+
embedJLine in Global := true
116+
115117
lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings ++ Seq[Setting[_]](
116118
organization := "org.scala-lang",
117119
scalaVersion := bootstrapScalaVersion,
@@ -206,7 +208,9 @@ lazy val commonSettings = clearSourceAndResourceDirectories ++ publishSettings +
206208

207209
// Don't log process output (e.g. of forked `compiler/runMain ...Main`), just pass it
208210
// directly to stdout
209-
outputStrategy in run := Some(StdoutOutput)
211+
outputStrategy in run := Some(StdoutOutput),
212+
Quiet.silenceScalaBinaryVersionWarning,
213+
Quiet.silenceIvyUpdateInfoLogging
210214
)
211215

212216
/** Extra post-processing for the published POM files. These are needed to create POMs that
@@ -442,30 +446,33 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target"
442446
// This is different from the ant build where all parts are combined into quick/repl, but
443447
// it is cleaner because it avoids circular dependencies.
444448
compile in Compile <<= (compile in Compile).dependsOn(Def.task {
445-
import java.util.jar._
446-
import collection.JavaConverters._
447-
val inputs: Iterator[JarJar.Entry] = {
448-
val repljlineClasses = (products in Compile in replJline).value.flatMap(base => Path.allSubpaths(base).map(x => (base, x._1)))
449-
val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data
450-
val jarFile = new JarFile(jlineJAR)
451-
val jarEntries = jarFile.entries.asScala.filterNot(_.isDirectory).map(entry => JarJar.JarEntryInput(jarFile, entry))
452-
def compiledClasses = repljlineClasses.iterator.map { case (base, file) => JarJar.FileInput(base, file) }
453-
(jarEntries ++ compiledClasses).filter(x =>
454-
x.name.endsWith(".class") || x.name.endsWith(".properties") || x.name.startsWith("META-INF/native") || x.name.startsWith("META-INF/maven")
449+
if (embedJLine.value) {
450+
import java.util.jar._
451+
import collection.JavaConverters._
452+
val inputs: Iterator[JarJar.Entry] = {
453+
val repljlineClasses = (products in Compile in replJline).value.flatMap(base => Path.allSubpaths(base).map(x => (base, x._1)))
454+
val jlineJAR = (dependencyClasspath in Compile).value.find(_.get(moduleID.key) == Some(jlineDep)).get.data
455+
val jarFile = new JarFile(jlineJAR)
456+
val jarEntries = jarFile.entries.asScala.filterNot(_.isDirectory).map(entry => JarJar.JarEntryInput(jarFile, entry))
457+
def compiledClasses = repljlineClasses.iterator.map { case (base, file) => JarJar.FileInput(base, file) }
458+
(jarEntries ++ compiledClasses).filter(x =>
459+
x.name.endsWith(".class") || x.name.endsWith(".properties") || x.name.startsWith("META-INF/native") || x.name.startsWith("META-INF/maven")
460+
)
461+
}
462+
import JarJar.JarJarConfig._
463+
val config: Seq[JarJar.JarJarConfig] = Seq(
464+
Rule("org.fusesource.**", "scala.tools.fusesource_embedded.@1"),
465+
Rule("jline.**", "scala.tools.jline_embedded.@1"),
466+
Rule("scala.tools.nsc.interpreter.jline.**", "scala.tools.nsc.interpreter.jline_embedded.@1"),
467+
Keep("scala.tools.**")
455468
)
469+
val outdir = (classDirectory in Compile).value
470+
JarJar(inputs, outdir, config)
456471
}
457-
import JarJar.JarJarConfig._
458-
val config: Seq[JarJar.JarJarConfig] = Seq(
459-
Rule("org.fusesource.**", "scala.tools.fusesource_embedded.@1"),
460-
Rule("jline.**", "scala.tools.jline_embedded.@1"),
461-
Rule("scala.tools.nsc.interpreter.jline.**", "scala.tools.nsc.interpreter.jline_embedded.@1"),
462-
Keep("scala.tools.**")
463-
)
464-
val outdir = (classDirectory in Compile).value
465-
JarJar(inputs, outdir, config)
466472
}),
467473
publishArtifact := false,
468474
connectInput in run := true
475+
469476
)
470477
.dependsOn(replJline)
471478

@@ -662,6 +669,7 @@ lazy val root = (project in file("."))
662669
)
663670
.aggregate(library, reflect, compiler, interactive, repl, replJline, replJlineEmbedded,
664671
scaladoc, scalap, partestExtras, junit, libraryAll, scalaDist).settings(
672+
Quiet.silenceIvyUpdateInfoLogging,
665673
sources in Compile := Seq.empty,
666674
onLoadMessage := """|*** Welcome to the sbt build definition for Scala! ***
667675
|This build definition has an EXPERIMENTAL status. If you are not
@@ -728,6 +736,9 @@ lazy val mkBin = taskKey[Seq[File]]("Generate shell script (bash or Windows batc
728736
lazy val mkQuick = taskKey[Unit]("Generate a full build, including scripts, in build/quick")
729737
lazy val mkPack = taskKey[Unit]("Generate a full build, including scripts, in build/pack")
730738

739+
// Add `embedJLine in Global := false` to `local.sbt` to silence noise until https://github.com/scala/scala-dev/issues/146 is fixed.
740+
lazy val embedJLine = settingKey[Boolean]("Embed a JarJar-shaded copy of JLine and code in interacing repl-jline")
741+
731742
// Defining these settings is somewhat redundant as we also redefine settings that depend on them.
732743
// However, IntelliJ's project import works better when these are set correctly.
733744
def clearSourceAndResourceDirectories = Seq(Compile, Test).flatMap(config => inConfig(config)(Seq(

project/Quiet.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import sbt._
2+
import Keys._
3+
4+
object Quiet {
5+
// Workaround SBT issue described:
6+
//
7+
// https://github.com/scala/scala-dev/issues/100
8+
def silenceScalaBinaryVersionWarning = ivyConfiguration := {
9+
ivyConfiguration.value match {
10+
case c: InlineIvyConfiguration =>
11+
val delegate = c.log
12+
val logger = new Logger {
13+
override def trace(t: => Throwable): Unit = delegate.trace(t)
14+
override def log(level: sbt.Level.Value, message: => String): Unit = {
15+
level match {
16+
case sbt.Level.Warn =>
17+
val message0 = message
18+
val newLevel = if (message.contains("differs from Scala binary version in project"))
19+
delegate.log(sbt.Level.Debug, message)
20+
else
21+
delegate.log(level, message)
22+
case _ => delegate.log(level, message)
23+
}
24+
}
25+
override def success(message: => String): Unit = delegate.success(message)
26+
}
27+
new InlineIvyConfiguration(c.paths, c.resolvers, c.otherResolvers, c.moduleConfigurations, c.localOnly, c.lock, c.checksums, c.resolutionCacheDir, c.updateOptions, logger)
28+
case x => x
29+
}
30+
}
31+
32+
def silenceIvyUpdateInfoLogging = logLevel in update := Level.Warn
33+
}

0 commit comments

Comments
 (0)