-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bumps sbt up * Adds classpath and bootclasspath to the compiler instance settings
- Loading branch information
1 parent
ae27655
commit 8694783
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
compiler/src/main/scala/org/scalaexercises/exercises/compiler/CompilerSettings.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.scalaexercises.exercises.compiler | ||
|
||
object CompilerSettings { | ||
|
||
private def classPathOfClass(className: String): List[String] = { | ||
val resource = className.split('.').mkString("/", "/", ".class") | ||
val path = getClass.getResource(resource).getPath | ||
if (path.indexOf("file:") >= 0) { | ||
val indexOfFile = path.indexOf("file:") + 5 | ||
val indexOfSeparator = path.lastIndexOf('!') | ||
List(path.substring(indexOfFile, indexOfSeparator)) | ||
} else { | ||
require(path.endsWith(resource)) | ||
List(path.substring(0, path.length - resource.length + 1)) | ||
} | ||
} | ||
|
||
private lazy val compilerPath = | ||
try classPathOfClass("scala.tools.nsc.Interpreter") | ||
catch { | ||
case e: Throwable => | ||
throw new RuntimeException( | ||
"Unable to load Scala interpreter from classpath (scala-compiler jar is missing?)", | ||
e | ||
) | ||
} | ||
|
||
private lazy val libPath = | ||
try classPathOfClass("scala.AnyVal") | ||
catch { | ||
case e: Throwable => | ||
throw new RuntimeException( | ||
"Unable to load scala base object from classpath (scala-library jar is missing?)", | ||
e | ||
) | ||
} | ||
|
||
lazy val paths: List[String] = compilerPath ::: libPath | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.2.8 | ||
sbt.version=1.3.13 |