From cbc0f8dfd19e2deb282be8b6564bb3e8192f32bb Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Mon, 5 Jun 2017 23:35:29 +0300 Subject: [PATCH] Cross-build for SBT 1.0.0-M6 --- build.sbt | 3 +++ project/build.properties | 2 +- .../spray/revolver/SbtCompat.scala | 17 +++++++++++++++++ .../spray/revolver/SbtCompat.scala | 7 +++++++ src/main/scala/spray/revolver/Actions.scala | 10 +++++----- src/main/scala/spray/revolver/AppProcess.scala | 3 ++- .../scala/spray/revolver/RevolverPlugin.scala | 9 +++++---- src/main/scala/spray/revolver/Utilities.scala | 2 +- 8 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 src/main/scala-sbt-0.13/spray/revolver/SbtCompat.scala create mode 100644 src/main/scala-sbt-1.0.0-M6/spray/revolver/SbtCompat.scala diff --git a/build.sbt b/build.sbt index d9e0eb0..0b99177 100644 --- a/build.sbt +++ b/build.sbt @@ -1,3 +1,6 @@ sbtPlugin := true scalacOptions := Seq("-deprecation", "-encoding", "utf8") + +crossSbtVersions := Vector("0.13.15", "1.0.0-M6") + diff --git a/project/build.properties b/project/build.properties index 64317fd..d9654cd 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.15 +sbt.version=0.13.16-M1 diff --git a/src/main/scala-sbt-0.13/spray/revolver/SbtCompat.scala b/src/main/scala-sbt-0.13/spray/revolver/SbtCompat.scala new file mode 100644 index 0000000..68afe00 --- /dev/null +++ b/src/main/scala-sbt-0.13/spray/revolver/SbtCompat.scala @@ -0,0 +1,17 @@ +package spray.revolver + +import sbt.ForkOptions + +object SbtCompat { + type Process = sbt.Process + + implicit class ForkOptionsCompatOps(val underlying: ForkOptions) extends AnyVal { + def withRunJVMOptions(runJVMOptions: Seq[String]): ForkOptions = { + underlying.copy(runJVMOptions = runJVMOptions) + } + + def withOutputStrategy(outputStrategy: sbt.OutputStrategy): ForkOptions = { + underlying.copy(outputStrategy = Option(outputStrategy)) + } + } +} diff --git a/src/main/scala-sbt-1.0.0-M6/spray/revolver/SbtCompat.scala b/src/main/scala-sbt-1.0.0-M6/spray/revolver/SbtCompat.scala new file mode 100644 index 0000000..9cc1cbc --- /dev/null +++ b/src/main/scala-sbt-1.0.0-M6/spray/revolver/SbtCompat.scala @@ -0,0 +1,7 @@ +package spray.revolver + +import sbt.ForkOptions + +object SbtCompat { + type Process = scala.sys.process.Process +} diff --git a/src/main/scala/spray/revolver/Actions.scala b/src/main/scala/spray/revolver/Actions.scala index 9b8a162..f9b9d6b 100644 --- a/src/main/scala/spray/revolver/Actions.scala +++ b/src/main/scala/spray/revolver/Actions.scala @@ -17,8 +17,9 @@ package spray.revolver import sbt.Keys._ -import sbt._ +import sbt.{Fork, ForkOptions, LoggedOutput, Logger, Path, ProjectRef, State, complete} import java.io.File +import SbtCompat._ object Actions { import Utilities._ @@ -131,10 +132,9 @@ object Actions { def forkRun(config: ForkOptions, mainClass: String, classpath: Seq[File], options: Seq[String], log: Logger, extraJvmArgs: Seq[String]): Process = { log.info(options.mkString("Starting " + mainClass + ".main(", ", ", ")")) val scalaOptions = "-classpath" :: Path.makeString(classpath) :: mainClass :: options.toList - val newOptions = - config.copy( - outputStrategy = Some(config.outputStrategy getOrElse LoggedOutput(log)), - runJVMOptions = config.runJVMOptions ++ extraJvmArgs) + val newOptions = config + .withOutputStrategy(config.outputStrategy getOrElse LoggedOutput(log)) + .withRunJVMOptions(config.runJVMOptions ++ extraJvmArgs) Fork.java.fork(newOptions, scalaOptions) } diff --git a/src/main/scala/spray/revolver/AppProcess.scala b/src/main/scala/spray/revolver/AppProcess.scala index 3c09a3e..4d7cd24 100644 --- a/src/main/scala/spray/revolver/AppProcess.scala +++ b/src/main/scala/spray/revolver/AppProcess.scala @@ -17,7 +17,8 @@ package spray.revolver import java.lang.{Runtime => JRuntime} -import sbt.{ProjectRef, Logger, Process} +import sbt.{ProjectRef, Logger} +import SbtCompat._ /** * A token which we put into the SBT state to hold the Process of an application running in the background. diff --git a/src/main/scala/spray/revolver/RevolverPlugin.scala b/src/main/scala/spray/revolver/RevolverPlugin.scala index a2bec28..ad770a8 100644 --- a/src/main/scala/spray/revolver/RevolverPlugin.scala +++ b/src/main/scala/spray/revolver/RevolverPlugin.scala @@ -85,10 +85,11 @@ object RevolverPlugin extends AutoPlugin { ForkOptions( javaHome.value, outputStrategy.value, - Nil, // bootJars is empty by default because only jars on the user's classpath should be on the boot classpath - workingDirectory = Some((baseDirectory in reStart).value), - runJVMOptions = (javaOptions in reStart).value, - connectInput = false + Vector.empty[File], // bootJars is empty by default because only jars on the user's classpath should be on the boot classpath + Option((baseDirectory in reStart).value), + (javaOptions in reStart).value.toVector, + false, + Map.empty[String, String] ) }, diff --git a/src/main/scala/spray/revolver/Utilities.scala b/src/main/scala/spray/revolver/Utilities.scala index 71e37c5..7afbaa8 100644 --- a/src/main/scala/spray/revolver/Utilities.scala +++ b/src/main/scala/spray/revolver/Utilities.scala @@ -58,7 +58,7 @@ object Utilities { ("_"+color._1) -> (color._2+UNDERLINED) def delimited(before: String, after: String)(mapping: (String, String)): (String, String) = (before+mapping._1+after, mapping._2) - def rgb(idx: Int): (String, String) = ("RGB"+idx, "\033[38;5;"+idx+"m") + def rgb(idx: Int): (String, String) = ("RGB"+idx, "\u001b[38;5;"+idx+"m") def replaceAll(message: String, replacer: String => String) = ansiTagMapping.foldLeft(message)((msg, tag) => msg.replaceAll(java.util.regex.Pattern.quote(tag._1), replacer(tag._2)))