mirror of https://github.com/sbt/sbt.git
launcher applies initial -Dkey=val arguments as settings for convenience
This commit is contained in:
parent
bf013d2b3f
commit
818f14a9a6
|
|
@ -7,19 +7,32 @@ import Pre._
|
||||||
import java.io.{File, FileInputStream, InputStreamReader}
|
import java.io.{File, FileInputStream, InputStreamReader}
|
||||||
import java.net.{MalformedURLException, URI, URL}
|
import java.net.{MalformedURLException, URI, URL}
|
||||||
import scala.collection.immutable.List
|
import scala.collection.immutable.List
|
||||||
|
import annotation.tailrec
|
||||||
|
|
||||||
object Configuration
|
object Configuration
|
||||||
{
|
{
|
||||||
|
final val SysPropPrefix = "-D"
|
||||||
def parse(file: URL, baseDirectory: File) = Using( new InputStreamReader(file.openStream, "utf8") )( (new ConfigurationParser).apply )
|
def parse(file: URL, baseDirectory: File) = Using( new InputStreamReader(file.openStream, "utf8") )( (new ConfigurationParser).apply )
|
||||||
def find(args: List[String], baseDirectory: File): (URL, List[String]) =
|
@tailrec def find(args: List[String], baseDirectory: File): (URL, List[String]) =
|
||||||
args match
|
args match
|
||||||
{
|
{
|
||||||
case head :: tail if head.startsWith("@")=> (directConfiguration(head.substring(1), baseDirectory), tail)
|
case head :: tail if head.startsWith("@") => (directConfiguration(head.substring(1), baseDirectory), tail)
|
||||||
|
case head :: tail if head.startsWith(SysPropPrefix) =>
|
||||||
|
setProperty(head stripPrefix SysPropPrefix)
|
||||||
|
find(tail, baseDirectory)
|
||||||
case _ =>
|
case _ =>
|
||||||
val propertyConfigured = System.getProperty("sbt.boot.properties")
|
val propertyConfigured = System.getProperty("sbt.boot.properties")
|
||||||
val url = if(propertyConfigured == null) configurationOnClasspath else configurationFromFile(propertyConfigured, baseDirectory)
|
val url = if(propertyConfigured == null) configurationOnClasspath else configurationFromFile(propertyConfigured, baseDirectory)
|
||||||
(url , args)
|
(url , args)
|
||||||
}
|
}
|
||||||
|
def setProperty(head: String)
|
||||||
|
{
|
||||||
|
val keyValue = head.split("=",2)
|
||||||
|
if(keyValue.length != 2)
|
||||||
|
System.err.println("Warning: invalid system property '" + head + "'")
|
||||||
|
else
|
||||||
|
System.setProperty(keyValue(0), keyValue(1))
|
||||||
|
}
|
||||||
def configurationOnClasspath: URL =
|
def configurationOnClasspath: URL =
|
||||||
{
|
{
|
||||||
resourcePaths.iterator.map(getClass.getResource).find(_ ne null) getOrElse
|
resourcePaths.iterator.map(getClass.getResource).find(_ ne null) getOrElse
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue