Skip to content

Commit

Permalink
Cross-build for SBT 1.0.0-M6
Browse files Browse the repository at this point in the history
  • Loading branch information
liff committed Jun 5, 2017
1 parent 4de4ab2 commit cbc0f8d
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 12 deletions.
3 changes: 3 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
sbtPlugin := true

scalacOptions := Seq("-deprecation", "-encoding", "utf8")

crossSbtVersions := Vector("0.13.15", "1.0.0-M6")

2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.15
sbt.version=0.13.16-M1
17 changes: 17 additions & 0 deletions src/main/scala-sbt-0.13/spray/revolver/SbtCompat.scala
Original file line number Diff line number Diff line change
@@ -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))
}
}
}
7 changes: 7 additions & 0 deletions src/main/scala-sbt-1.0.0-M6/spray/revolver/SbtCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package spray.revolver

import sbt.ForkOptions

object SbtCompat {
type Process = scala.sys.process.Process
}
10 changes: 5 additions & 5 deletions src/main/scala/spray/revolver/Actions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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._
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/spray/revolver/AppProcess.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions src/main/scala/spray/revolver/RevolverPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
},

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/spray/revolver/Utilities.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down

0 comments on commit cbc0f8d

Please sign in to comment.