From 89a3e4982f1bb735e7b6966fcb5b4f9d3b37dee4 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Wed, 8 Oct 2014 15:00:48 -0400 Subject: [PATCH] Add escape hatch to old parser in case we run into problems. Just make sure users have the means to still build in case there's any issues we missed. This code should be removed in sbt 1.0. --- .../main/scala/sbt/EvaluateConfigurations.scala | 15 +++++++++++---- notes/0.13.7.markdown | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/main/src/main/scala/sbt/EvaluateConfigurations.scala b/main/src/main/scala/sbt/EvaluateConfigurations.scala index 3763e315c..80b3f8d89 100644 --- a/main/src/main/scala/sbt/EvaluateConfigurations.scala +++ b/main/src/main/scala/sbt/EvaluateConfigurations.scala @@ -212,16 +212,23 @@ object EvaluateConfigurations { private[this] def fstS(f: String => Boolean): ((String, Int)) => Boolean = { case (s, i) => f(s) } private[this] def firstNonSpaceIs(lit: String) = (_: String).view.dropWhile(isSpace).startsWith(lit) private[this] def or[A](a: A => Boolean, b: A => Boolean): A => Boolean = in => a(in) || b(in) + + /** Configures the use of the old sbt parser. */ + private[sbt] def useOldParser: Boolean = + sys.props.get("sbt.parser.simple").map(java.lang.Boolean.parseBoolean).getOrElse(false) /** * Splits a set of lines into (imports, expressions). That is, * anything on the right of the tuple is a scala expression (definition or setting). */ private[sbt] def splitExpressions(file: File, lines: Seq[String]): (Seq[(String, Int)], Seq[(String, LineRange)]) = { - val split = SbtParser(file, lines) - // TODO - Look at pulling the parsed expression trees from the SbtParser and stitch them back into a different - // scala compiler rather than re-parsing. - (split.imports, split.settings) + if (useOldParser) splitExpressions(lines) + else { + val split = SbtParser(file, lines) + // TODO - Look at pulling the parsed expression trees from the SbtParser and stitch them back into a different + // scala compiler rather than re-parsing. + (split.imports, split.settings) + } } @deprecated("This method is no longer part of the public API.", "0.13.7") diff --git a/notes/0.13.7.markdown b/notes/0.13.7.markdown index f3ab49c72..2c0f20ed8 100644 --- a/notes/0.13.7.markdown +++ b/notes/0.13.7.markdown @@ -66,6 +66,8 @@ Starting sbt 0.13.7, build.sbt will be parsed using a customized Scala parser. This eliminates the requirement to use blank line as the delimiter between each settings, and also allows blank lines to be inserted at arbitrary position within a block. +This feature can be disabled, if necessary, via the -Dsbt.parser.simple=true flag. + This feature was contributed by [Andrzej Jozwik (@ajozwik)](https://github.com/ajozwik), [Rafał Krzewski (@rkrzewski)][@rkrzewski] and others at [@WarsawScala][@WarsawScala] inspired by Typesafe's [@gkossakowski][@gkossakowski] organizing multiple [meetups](http://blog.japila.pl/2014/07/gkossakowski-on-warszawscala-about-how-to-patch-scalasbt/) and [hackathons](http://blog.japila.pl/2014/07/hacking-scalasbt-with-gkossakowski-on-warszawscala-meetup-in-javeo_eu/) on how to patch sbt with the focus on this blank line issue. Dziękujemy! [#1606][1606] ### Custom Maven local repository location