Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 47 lines (44 sloc) 1.307 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah
*/
package xsbt.boot

import Pre._
import java.io.{File, FileInputStream}
import java.util.Properties

object ResolveVersions
{
def apply(conf: LaunchConfiguration): LaunchConfiguration = (new ResolveVersions(conf))()
private def trim(s: String) = if(s eq null) None else notEmpty(s.trim)
private def notEmpty(s: String) = if(isEmpty(s)) None else Some(s)
private def readProperties(propertiesFile: File) =
{
val properties = new Properties
if(propertiesFile.exists)
Using( new FileInputStream(propertiesFile) )( properties.load )
properties
}
}

import ResolveVersions.{readProperties, trim}
final class ResolveVersions(conf: LaunchConfiguration) extends NotNull
{
private def propertiesFile = conf.boot.properties
private lazy val properties = readProperties(propertiesFile)
def apply(): LaunchConfiguration =
{
import conf._
val scalaVersion = resolve(conf.scalaVersion)
val appVersion = resolve(app.version)
withVersions(scalaVersion, appVersion)
}
def resolve(v: Version): String =
{
v match
{
case e: Version.Explicit => e.value
case i: Version.Implicit =>
trim(properties.getProperty(i.name)) orElse
i.default getOrElse
error("No " + i.name + " specified in " + propertiesFile)
}
}
}
Something went wrong with that request. Please try again.