Browse files

Provide a better error message when an older launcher is used with 0.…

…13 and JLine classes are incompatible.
  • Loading branch information...
1 parent 9f75019 commit 001bd6cb9f203c42e951b2e125b8854ce2ca632a @harrah harrah committed Jul 8, 2013
Showing with 11 additions and 3 deletions.
  1. +2 −3 main/src/main/scala/sbt/Main.scala
  2. +9 −0 util/log/src/main/scala/sbt/ConsoleLogger.scala
View
5 main/src/main/scala/sbt/Main.scala
@@ -51,9 +51,8 @@ object StandardMain
/** The common interface to standard output, used for all built-in ConsoleLoggers. */
val console = ConsoleOut.systemOutOverwrite(ConsoleOut.overwriteContaining("Resolving "))
- def initialGlobalLogging: GlobalLogging =
- GlobalLogging.initial(MainLogging.globalDefault(console), File.createTempFile("sbt",".log"), console)
-
+ def initialGlobalLogging: GlobalLogging = GlobalLogging.initial(MainLogging.globalDefault(console), File.createTempFile("sbt",".log"), console)
+
def initialState(configuration: xsbti.AppConfiguration, initialDefinitions: Seq[Command], preCommands: Seq[String]): State =
{
val commands = preCommands ++ configuration.arguments.map(_.trim)
View
9 util/log/src/main/scala/sbt/ConsoleLogger.scala
@@ -78,6 +78,7 @@ object ConsoleLogger
val value = System.getProperty("sbt.log.format")
if(value eq null) (ansiSupported && !getBoolean("sbt.log.noformat")) else parseBoolean(value)
}
+ private[this] def jline1to2CompatMsg = "Found class jline.Terminal, but interface was expected"
private[this] def ansiSupported =
try {
@@ -86,7 +87,15 @@ object ConsoleLogger
terminal.isAnsiSupported
} catch {
case e: Exception => !isWindows
+
+ // sbt 0.13 drops JLine 1.0 from the launcher and uses 2.x as a normal dependency
+ // when 0.13 is used with a 0.12 launcher or earlier, the JLine classes from the launcher get loaded
+ // this results in a linkage error as detected below. The detection is likely jvm specific, but the priority
+ // is avoiding mistakenly identifying something as a launcher incompatibility when it is not
+ case e: IncompatibleClassChangeError if e.getMessage == jline1to2CompatMsg =>
+ throw new IncompatibleClassChangeError("JLine incompatibility detected. Check that the sbt launcher is version 0.13.x or later.")
}
+
val noSuppressedMessage = (_: SuppressedTraceContext) => None
private[this] def os = System.getProperty("os.name")

0 comments on commit 001bd6c

Please sign in to comment.