Skip to content

Commit

Permalink
Forward port sbt/sbt#3701, JDK9/Scala 2.{10,11} overcompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym committed Nov 1, 2017
1 parent 8c42c1f commit 201f7d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions internal/compiler-bridge/src/main/scala/xsbt/Dependency.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ final class Dependency(val global: CallbackGlobal) extends LocateClassFile with
// The dependency comes from a JAR
for {
zip <- zipEntry.underlyingSource
classFile <- Option(zip.file)
} binaryDependency(classFile, binaryClassName)
jarFile <- Option(zip.file)
if !jarFile.isDirectory // workaround for JDK9 and Scala 2.10/2.11, see https://github.com/sbt/sbt/pull/3701
} binaryDependency(jarFile, binaryClassName)
case pf: PlainFile =>
// The dependency comes from a class file
binaryDependency(pf.file, binaryClassName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ package internal
package inc

import xsbti.ArtifactInfo

import scala.util
import java.io.File
import CompilerArguments.{ absString, BootClasspathOption }

import CompilerArguments.{BootClasspathOption, absString}
import sbt.IO
import sbt.io.IO
import sbt.io.syntax._

Expand Down Expand Up @@ -82,7 +85,13 @@ final class CompilerArguments(
* @param addLibrary Flag to return the Scala library.
*/
def createBootClasspath(addLibrary: Boolean): String = {
val originalBoot = System.getProperty("sun.boot.class.path", "")
def findBoot: String = {
import scala.collection.JavaConverters._
System.getProperties.asScala.iterator.collectFirst {
case (k, v) if k.endsWith(".boot.class.path") => v
}.getOrElse("")
}
val originalBoot = Option(System.getProperty("sun.boot.class.path", null)).getOrElse(findBoot)
if (addLibrary) {
val newBootPrefix =
if (originalBoot.isEmpty) ""
Expand All @@ -109,7 +118,7 @@ final class CompilerArguments(
bootClasspath(hasLibrary(classpath))

def extClasspath: Seq[File] =
(IO.parseClasspath(System.getProperty("java.ext.dirs", "")) * "*.jar").get
List("java.ext.dirs", "scala.ext.dirs").flatMap(k => (IO.parseClasspath(System.getProperty(k, "")) * "*.jar").get)

private[this] def include(flag: Boolean, jars: File*) =
if (flag || ScalaInstance.isDotty(scalaInstance.version)) jars
Expand Down

0 comments on commit 201f7d3

Please sign in to comment.