From fab20c73bf083b3d91cbad0921b0dc7367af0759 Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Fri, 8 Apr 2016 17:55:38 +0200 Subject: [PATCH] Add `scala-reflect.jar` to JARs of `StaticScalaProvider` It turns out we need to have `scala-reflect.jar` on classpath to compile the compiler bridge for the static scala instance of the launcher. --- build.sbt | 2 +- sbt/src/main/scala/Main.scala | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index afe8437c5..043984488 100644 --- a/build.sbt +++ b/build.sbt @@ -375,7 +375,7 @@ lazy val compilerIvyProj = (project in compilePath / "ivy"). val compilerBridgeSrc = (Keys.packageSrc in (compileInterfaceProj, Compile)).value val xsbtiJAR = (Keys.packageBin in (interfaceProj, Compile)).value // They are immediately used by the static launcher. - val included = Set("scala-compiler.jar", "scala-library.jar") + val included = Set("scala-compiler.jar", "scala-library.jar", "scala-reflect.jar") val scalaJars = (externalDependencyClasspath in Compile).value.map(_.data).filter(j => included contains j.getName) Seq(compilerBridgeSrc, xsbtiJAR) ++ scalaJars } diff --git a/sbt/src/main/scala/Main.scala b/sbt/src/main/scala/Main.scala index fcf8e715b..2442f7a5d 100644 --- a/sbt/src/main/scala/Main.scala +++ b/sbt/src/main/scala/Main.scala @@ -20,6 +20,8 @@ private object StaticUtils { val COMPILER_JAR = "scala-compiler.jar" val LIBRARY = "library" val LIBRARY_JAR = "scala-library.jar" + val REFLECT = "reflect" + val REFLECT_JAR = "scala-reflect.jar" val XSBTI = "xsbti" val XSBTI_JAR = s"interface-${sbtApplicationID.version}.jar" val thisJAR: File = new File(getClass.getProtectionDomain().getCodeSource().getLocation().toURI().getPath()) @@ -109,7 +111,7 @@ private class StaticScalaProvider(appProvider: StaticAppProvider) extends xsbti. override def app(id: xsbti.ApplicationID): xsbti.AppProvider = appProvider override def compilerJar(): File = getComponent(StaticUtils.COMPILER) override def libraryJar(): File = getComponent(StaticUtils.LIBRARY) - override def jars(): Array[File] = Array(compilerJar, libraryJar) + override def jars(): Array[File] = Array(compilerJar, libraryJar, getComponent(StaticUtils.REFLECT)) override def loader(): ClassLoader = new URLClassLoader(jars map (_.toURI.toURL)) override def version(): String = StaticUtils.getProperty(loader, "compiler.properties", "version.number") getOrElse "unknown" } @@ -124,6 +126,10 @@ private class StaticAppProvider(appConfig: StaticAppConfiguration) extends xsbti installFromResources(StaticUtils.LIBRARY_JAR, StaticUtils.LIBRARY) } + if (components.component(StaticUtils.REFLECT).isEmpty) { + installFromResources(StaticUtils.REFLECT_JAR, StaticUtils.REFLECT) + } + if (components.component(StaticUtils.XSBTI).isEmpty) { installFromResources(StaticUtils.XSBTI_JAR, StaticUtils.XSBTI) }