Skip to content

Commit

Permalink
[WIP] sbt 1.2.0 (#1500)
Browse files Browse the repository at this point in the history
sbt 1.2.0
  • Loading branch information
octonato authored and marcospereira committed Aug 13, 2018
1 parent 917fc7a commit 4d6c864
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import sbt.CrossVersion._
ivyLoggingLevel in ThisBuild := UpdateLogging.Quiet

def defineSbtVersion(scalaBinVer: String): String = scalaBinVer match {
case "2.12" => "1.1.6"
case "2.12" => "1.2.1"
case _ => "0.13.17"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ package sbt {

def reapply(
newSettings: Seq[Setting[_]],
structure: BuildStructure
)(implicit display: Show[ScopedKey[_]]): BuildStructure = Load.reapply(newSettings, structure)
structure: BuildStructure,
log: Logger
)(implicit display: Show[ScopedKey[_]]): BuildStructure = Load.reapply(newSettings, structure, log)

def finalTransforms(ss: Seq[Setting[_]]): Seq[Setting[_]] = Load.finalTransforms(ss)

Expand Down Expand Up @@ -120,7 +121,8 @@ package com.lightbend.lagom.sbt {

// Now we recreate the structure, this is where the structure data is calculated, which evaluates all the settings
// and works out all the dependencies.
val reindexedStructure = sbt.LagomLoad.reapply(newSession.mergeSettings, structureWithNewProject)
val logger = extracted.get(Keys.sLog in ThisBuild)
val reindexedStructure = sbt.LagomLoad.reapply(newSession.mergeSettings, structureWithNewProject, logger)

// And finally, put all the new stuff in a new state.
state.copy(attributes = state.attributes.put(stateBuildStructure, reindexedStructure).put(sessionSettings, newSession))
Expand Down
13 changes: 8 additions & 5 deletions dev/sbt-plugin/src/sbt-test/sbt-plugin/distribution/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ lazy val playProj = (project in file("playProj")).enablePlugins(PlayJava, LagomP
val checkStartScriptLagomProj = taskKey[Unit]("checkStartScriptLagomProj")
val checkStartScriptPlayProj = taskKey[Unit]("checkStartScriptPlayProj")

checkStartScriptLagomProj := checkStartScriptTask(lagomProj)
checkStartScriptPlayProj := checkStartScriptTask(playProj)
checkStartScriptLagomProj := checkStartScriptTask(lagomProj).value
checkStartScriptPlayProj := checkStartScriptTask(playProj).value

def checkStartScriptTask(p: Project) = Def.task {
val startScript = ((target in p).value) / "universal" / "stage" / "bin" / ((name in p).value)
Expand All @@ -34,11 +34,14 @@ def checkStartScriptTask(p: Project) = Def.task {
}
val contents = IO.read(startScript)
val lines = IO.readLines(startScript)
if (!contents.contains( """app_mainclass=("play.core.server.ProdServerStart")""")) {
// For sbt 0.13, the main class name is declared between double quotes. For sbt 1.2.x it is not.
if (contents.contains("app_mainclass=(play.core.server.ProdServerStart)") || contents.contains( """app_mainclass=("play.core.server.ProdServerStart")""")) {
// Also check for classpath declaration
lines.find(_ startsWith "declare -r app_classpath")
.getOrElse( startScriptError(contents, "Start script doesn't declare app_classpath"))
} else {
startScriptError(contents, "Cannot find the declaration of the main class in the script")
}
val appClasspath = lines.find(_ startsWith "declare -r app_classpath")
.getOrElse( startScriptError(contents, "Start script doesn't declare app_classpath"))
}

InputKey[Unit]("absence") := {
Expand Down

0 comments on commit 4d6c864

Please sign in to comment.