aboutsummaryrefslogtreecommitdiff
path: root/compiler/test/dotty/Jars.scala
blob: 06df9c891290a99133c1c6e6809c3db1284967a2 (plain) (blame)
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
package dotty

/** Jars used when compiling test, normally set from the sbt build */
object Jars {
  val dottyLib: String = sys.env.get("DOTTY_LIB")
    .getOrElse(sys.props("dotty.tests.classes.library"))

  val dottyCompiler: String = sys.env.get("DOTTY_COMPILER")
    .getOrElse(sys.props("dotty.tests.classes.compiler"))

  val dottyInterfaces: String = sys.env.get("DOTTY_INTERFACE")
    .getOrElse(sys.props("dotty.tests.classes.interfaces"))

  val dottyExtras: List[String] = Option(sys.env.get("DOTTY_EXTRAS")
    .getOrElse(sys.props("dotty.tests.extraclasspath")))
    .map(_.split(":").toList).getOrElse(Nil)

  val dottyReplDeps: List[String] = dottyLib :: dottyExtras

  val dottyTestDeps: List[String] =
    dottyLib :: dottyCompiler :: dottyInterfaces :: dottyExtras


  def scalaLibraryFromRuntime: String = findJarFromRuntime("scala-library-2.")

  private def findJarFromRuntime(partialName: String) = {
    val urls = ClassLoader.getSystemClassLoader.asInstanceOf[java.net.URLClassLoader].getURLs.map(_.getFile.toString)
    urls.find(_.contains(partialName)).getOrElse {
      throw new java.io.FileNotFoundException(
        s"""Unable to locate $partialName on classpath:\n${urls.toList.mkString("\n")}"""
      )
    }
  }

}