Browse files

closes #83: Generalize support for scalac settings

  • Loading branch information...
1 parent b93ae33 commit 622c6d6cc5cb8813598009c84d0f9b0a2da1887b Heiko Seeberger committed Jan 25, 2012
View
24 sbteclipse-core/src/main/scala/com/typesafe/sbteclipse/core/Eclipse.scala
@@ -58,7 +58,7 @@ import scalaz.effects._
private object Eclipse {
- val SettingFormat = """-?([^:]*):?(.*)""".r
+ val SettingFormat = """-([^:]*):?(.*)""".r
val FileSep = System.getProperty("file.separator")
@@ -262,7 +262,25 @@ private object Eclipse {
}
def scalacOptions(ref: ProjectRef)(implicit state: State) =
- evaluateTask(Keys.scalacOptions, ref) map { options =>
+ evaluateTask(Keys.scalacOptions, ref) map (options =>
+ if (options.isEmpty) Nil
+ else {
+ def pluginValues(value: String) =
+ value split "," map (_.trim) filterNot (_ contains "org.scala-lang.plugins/continuations")
+ options.zipAll(options.tail, "-", "-") collect {
+ case (SettingFormat("Xplugin", value), _) if !pluginValues(value).isEmpty =>
+ "Xplugin" -> (pluginValues(value) mkString ",")
+ case (SettingFormat(key, value), next) if next startsWith "-" =>
+ key -> (if (!value.isEmpty) value else "true")
+ case (SettingFormat(key, _), next) =>
+ key -> next
+ } match {
+ case Nil => Nil
+ case options => ("scala.compiler.useProjectSettings" -> "true") +: options
+ }
+ }
+ )
+ /*
def values(value: String) =
value split "," map (_.trim) filterNot (_ contains "org.scala-lang.plugins/continuations")
options collect {
@@ -274,7 +292,7 @@ private object Eclipse {
case Nil => Nil
case os => ("scala.compiler.useProjectSettings" -> "true") +: os
}
- }
+ */
def externalDependencies(
ref: ProjectRef,
View
4 sbteclipse-plugin/src/sbt-test/sbteclipse/02-contents/build.sbt
@@ -147,7 +147,9 @@ TaskKey[Unit]("verify-settings") <<= baseDirectory map { dir =>
val expected = Map(
"scala.compiler.useProjectSettings" -> "true",
"unchecked" -> "true",
- "deprecation" -> "true"
+ "deprecation" -> "true",
+ "Xplugin" -> "foo",
+ "Xelide-below" -> "0"
)
if (settings != expected) error("Expected settings to be '%s', but was '%s'!".format(expected, settings))
}
View
2 sbteclipse-plugin/src/sbt-test/sbteclipse/02-contents/project/Build.scala
@@ -57,7 +57,7 @@ object Build extends Build {
"junit" % "junit" % "4.7" % "it"
),
retrieveManaged := true,
- scalacOptions := Seq("-unchecked", "-deprecation"),
+ scalacOptions := Seq("-unchecked", "-deprecation", "-Xelide-below", "0", "-Xplugin:foo,org.scala-lang.plugins/continuations"),
EclipseKeys.configurations := Set(Configurations.Compile, Configurations.IntegrationTest)
),
dependencies = Seq(suba, suba % "test->compile", subc % "test->test")

0 comments on commit 622c6d6

Please sign in to comment.