mirror of https://github.com/sbt/sbt.git
jline support for 2.9
This commit is contained in:
parent
e7b47d67e7
commit
ec8c5434af
|
|
@ -68,7 +68,7 @@ private object BootConfiguration
|
|||
/** The name of the directory to retrieve the application and its dependencies to.*/
|
||||
def appDirectoryName(appID: xsbti.ApplicationID, sep: String) = appID.groupID + sep + appID.name + sep + appID.version
|
||||
/** The name of the directory in the boot directory to put all jars for the given version of scala in.*/
|
||||
def baseDirectoryName(scalaVersion: String) = "scala-" + scalaVersion
|
||||
def baseDirectoryName(scalaVersion: String) = if(scalaVersion.isEmpty) "other" else "scala-" + scalaVersion
|
||||
}
|
||||
private object ProxyProperties
|
||||
{
|
||||
|
|
|
|||
|
|
@ -83,12 +83,26 @@ class Launch private[xsbt](val bootDirectory: File, val ivyOptions: IvyOptions)
|
|||
private val scalaProviders = new Cache[String, ScalaProvider](new ScalaProvider(_))
|
||||
def getScala(version: String): xsbti.ScalaProvider = scalaProviders(version)
|
||||
|
||||
lazy val topLoader = new BootFilteredLoader(getClass.getClassLoader)
|
||||
lazy val topLoader = (new JNAProvider).loader
|
||||
val updateLockFile = new File(bootDirectory, "sbt.boot.lock")
|
||||
|
||||
def globalLock: xsbti.GlobalLock = Locks
|
||||
def cacheDirectory = ivyOptions.cacheDirectory.orNull
|
||||
|
||||
class JNAProvider extends Provider
|
||||
{
|
||||
lazy val id = new Application("net.java.dev.jna", "jna", new Explicit("3.2.3"), "", Nil, false, array())
|
||||
lazy val configuration = new UpdateConfiguration(bootDirectory, ivyOptions.cacheDirectory, "", repositories)
|
||||
lazy val libDirectory = new File(bootDirectory, baseDirectoryName(""))
|
||||
def baseDirectories: List[File] = new File(libDirectory, appDirectoryName(id.toID, File.separator)) :: Nil
|
||||
def testLoadClasses: List[String] = "com.sun.jna.Function" :: Nil
|
||||
def extraClasspath = array()
|
||||
def target = new UpdateApp(id, Nil)
|
||||
lazy val parentLoader = new BootFilteredLoader(getClass.getClassLoader)
|
||||
def failLabel = "JNA"
|
||||
def lockFile = updateLockFile
|
||||
}
|
||||
|
||||
class ScalaProvider(val version: String) extends xsbti.ScalaProvider with Provider
|
||||
{
|
||||
def launcher: xsbti.Launcher = Launch.this
|
||||
|
|
@ -97,9 +111,9 @@ class Launch private[xsbt](val bootDirectory: File, val ivyOptions: IvyOptions)
|
|||
lazy val configuration = new UpdateConfiguration(bootDirectory, ivyOptions.cacheDirectory, version, repositories)
|
||||
lazy val libDirectory = new File(configuration.bootDirectory, baseDirectoryName(version))
|
||||
lazy val scalaHome = new File(libDirectory, ScalaDirectoryName)
|
||||
def compilerJar = new File(scalaHome,CompilerModuleName + ".jar")
|
||||
def compilerJar = new File(scalaHome, CompilerModuleName + ".jar")
|
||||
def libraryJar = new File(scalaHome, LibraryModuleName + ".jar")
|
||||
override def classpath = array(compilerJar, libraryJar)
|
||||
override def classpath = Provider.getJars(scalaHome :: Nil)
|
||||
def baseDirectories = List(scalaHome)
|
||||
def testLoadClasses = TestLoadScalaClasses
|
||||
def target = new UpdateScala(Value.get(classifiers.forScala))
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ import util.{DefaultMessageLogger, Message, MessageLoggerEngine}
|
|||
|
||||
import BootConfiguration._
|
||||
|
||||
sealed trait UpdateTarget extends NotNull { def tpe: String; def classifiers: List[String] }
|
||||
sealed trait UpdateTarget { def tpe: String; def classifiers: List[String] }
|
||||
final class UpdateScala(val classifiers: List[String]) extends UpdateTarget { def tpe = "scala" }
|
||||
final class UpdateApp(val id: Application, val classifiers: List[String]) extends UpdateTarget { def tpe = "app" }
|
||||
|
||||
final class UpdateConfiguration(val bootDirectory: File, val ivyCacheDirectory: Option[File], val scalaVersion: String, val repositories: List[Repository]) extends NotNull
|
||||
final class UpdateConfiguration(val bootDirectory: File, val ivyCacheDirectory: Option[File], val scalaVersion: String, val repositories: List[Repository])
|
||||
|
||||
/** Ensures that the Scala and application jars exist for the given versions or else downloads them.*/
|
||||
final class Update(config: UpdateConfiguration)
|
||||
|
|
@ -97,7 +97,7 @@ final class Update(config: UpdateConfiguration)
|
|||
target match
|
||||
{
|
||||
case u: UpdateScala =>
|
||||
addDependency(moduleID, ScalaOrg, CompilerModuleName, scalaVersion, "default", u.classifiers)
|
||||
addDependency(moduleID, ScalaOrg, CompilerModuleName, scalaVersion, "default;optional", u.classifiers)
|
||||
addDependency(moduleID, ScalaOrg, LibraryModuleName, scalaVersion, "default", u.classifiers)
|
||||
System.out.println("Getting Scala " + scalaVersion + " ...")
|
||||
case u: UpdateApp =>
|
||||
|
|
@ -122,7 +122,8 @@ final class Update(config: UpdateConfiguration)
|
|||
private def addDependency(moduleID: DefaultModuleDescriptor, organization: String, name: String, revision: String, conf: String, classifiers: List[String])
|
||||
{
|
||||
val dep = new DefaultDependencyDescriptor(moduleID, createID(organization, name, revision), false, false, true)
|
||||
dep.addDependencyConfiguration(DefaultIvyConfiguration, conf)
|
||||
for(c <- conf.split(";"))
|
||||
dep.addDependencyConfiguration(DefaultIvyConfiguration, c)
|
||||
for(classifier <- classifiers)
|
||||
addClassifier(dep, name, classifier)
|
||||
moduleID.addDependency(dep)
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ object ScalaInstance
|
|||
def apply(version: String, launcher: xsbti.Launcher): ScalaInstance =
|
||||
apply(version, launcher.getScala(version))
|
||||
def apply(version: String, provider: xsbti.ScalaProvider): ScalaInstance =
|
||||
new ScalaInstance(version, provider.loader, provider.libraryJar, provider.compilerJar, Nil)
|
||||
new ScalaInstance(version, provider.loader, provider.libraryJar, provider.compilerJar, provider.jars - provider.libraryJar - provider.compilerJar)
|
||||
|
||||
def apply(scalaHome: File, launcher: xsbti.Launcher): ScalaInstance =
|
||||
apply(libraryJar(scalaHome), compilerJar(scalaHome), launcher)
|
||||
apply(libraryJar(scalaHome), compilerJar(scalaHome), launcher, jlineJar(scalaHome))
|
||||
def apply(version: String, scalaHome: File, launcher: xsbti.Launcher): ScalaInstance =
|
||||
apply(version, libraryJar(scalaHome), compilerJar(scalaHome), launcher)
|
||||
apply(version, libraryJar(scalaHome), compilerJar(scalaHome), launcher, jlineJar(scalaHome))
|
||||
def apply(libraryJar: File, compilerJar: File, launcher: xsbti.Launcher, extraJars: File*): ScalaInstance =
|
||||
{
|
||||
val loader = scalaLoader(launcher, libraryJar :: compilerJar :: extraJars.toList)
|
||||
|
|
@ -43,6 +43,7 @@ object ScalaInstance
|
|||
|
||||
private def compilerJar(scalaHome: File) = scalaJar(scalaHome, "scala-compiler.jar")
|
||||
private def libraryJar(scalaHome: File) = scalaJar(scalaHome, "scala-library.jar")
|
||||
private def jlineJar(scalaHome: File) = scalaJar(scalaHome, "jline.jar")
|
||||
def scalaJar(scalaHome: File, name: String) = new File(scalaHome, "lib" + File.separator + name)
|
||||
|
||||
/** Gets the version of Scala in the compiler.properties file from the loader.*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue