mirror of https://github.com/sbt/sbt.git
auto-generate conscript launchconfigs from launcher boot.properties
This commit is contained in:
parent
1377840cdf
commit
989c1d3dc6
|
|
@ -205,7 +205,8 @@ object Sbt extends Build
|
|||
import Sxr.sxr
|
||||
def releaseSettings = Release.settings(nonRoots, proguard in Proguard)
|
||||
def rootSettings = releaseSettings ++ Docs.settings ++ LaunchProguard.settings ++ LaunchProguard.specific(launchSub) ++
|
||||
Sxr.settings ++ docSetting ++ Util.publishPomSettings ++ otherRootSettings ++ proguardedLauncherSettings
|
||||
Sxr.settings ++ docSetting ++ Util.publishPomSettings ++ otherRootSettings ++ proguardedLauncherSettings ++
|
||||
Transform.conscriptSettings(launchSub)
|
||||
def otherRootSettings = Seq(
|
||||
scripted <<= scriptedTask,
|
||||
scriptedSource <<= (sourceDirectory in sbtSub) / "sbt-test",
|
||||
|
|
@ -230,7 +231,7 @@ object Sbt extends Build
|
|||
autoScalaLibrary := false,
|
||||
description := "sbt application launcher",
|
||||
publishLauncher <<= publish,
|
||||
packageBin in Compile <<= (proguard in Proguard).map(x => x)
|
||||
packageBin in Compile <<= (proguard in Proguard, Transform.conscriptConfigs).map( (x,y) => x)
|
||||
)
|
||||
def docSetting = inConfig(Compile)(inTask(sxr)(Defaults.docSetting(doc in ThisScope.copy(task = Global, config = Global))))
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,34 @@ object Transform
|
|||
lazy val inputResources = TaskKey[Seq[File]]("input-resources")
|
||||
lazy val resourceProperties = TaskKey[Map[String,String]]("resource-properties")
|
||||
|
||||
lazy val conscriptConfigs = TaskKey[Unit]("conscript-configs")
|
||||
|
||||
def conscriptSettings(launch: Reference) = Seq(
|
||||
conscriptConfigs <<= (managedResources in launch in Compile, sourceDirectory in Compile).map { (res, src) =>
|
||||
val source = res.filter(_.getName == "sbt.boot.properties").headOption getOrElse error("No managed boot.properties file.")
|
||||
copyConscriptProperties(source, src / "conscript")
|
||||
()
|
||||
}
|
||||
)
|
||||
def copyConscriptProperties(source: File, conscriptBase: File): Seq[File] =
|
||||
{
|
||||
IO.delete(conscriptBase)
|
||||
val pairs = Seq(
|
||||
"sbt.xMain" -> "sbt",
|
||||
"sbt.ScriptMain" -> "scalas",
|
||||
"sbt.ConsoleMain" -> "screpl"
|
||||
)
|
||||
for( (main, dir) <- pairs) yield {
|
||||
val file = conscriptBase / dir / "launchconfig"
|
||||
copyPropertiesFile(source, main, file)
|
||||
file
|
||||
}
|
||||
}
|
||||
def copyPropertiesFile(source: File, newMain: String, target: File) {
|
||||
def subMain(line: String): String = if(line.trim.startsWith("class:")) " class: " + newMain else line
|
||||
IO.writeLines(target, IO.readLines(source) map subMain)
|
||||
}
|
||||
|
||||
def crossGenSettings = transSourceSettings ++ seq(
|
||||
sourceProperties := Map("cross.package0" -> "sbt", "cross.package1" -> "cross")
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue