Skip to content

Commit 63303e3

Browse files
committed
Updated plugin test support to use scala jars from ivy and not sbt
1 parent 81b0359 commit 63303e3

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/test/scala/scoverage/PluginRunner.scala

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import scala.collection.mutable.ListBuffer
1010
/** @author Stephen Samuel */
1111
trait PluginSupport {
1212

13-
val scalaVersion = "2.10.3"
13+
val scalaVersion = "2.10.4"
1414
val shortScalaVersion = "2.10"
1515

1616
val settings = new scala.tools.nsc.Settings
@@ -26,6 +26,7 @@ trait PluginSupport {
2626
def writeCodeSnippetToTempFile(code: String): File = {
2727
val file = File.createTempFile("scoverage_snippet", ".scala")
2828
org.apache.commons.io.FileUtils.write(file, code)
29+
file.deleteOnExit()
2930
file
3031
}
3132

@@ -44,24 +45,21 @@ trait PluginSupport {
4445
}
4546

4647
def getScalaJars: List[File] = {
47-
val scalaJars = List("scala-compiler.jar", "scala-library.jar", "scala-reflect.jar")
48+
val scalaJars = List("scala-compiler", "scala-library", "scala-reflect")
4849
scalaJars.map(findScalaJar)
4950
}
5051

51-
def findScalaJar(jarName: String): File = {
52-
val userHome = System.getProperty("user.home")
53-
val sbtHome = userHome + "/.sbt"
54-
val sbtScalaLibs = sbtHome + "/boot/scala-" + scalaVersion + "/lib"
55-
val file = new File(sbtScalaLibs + "/" + jarName)
56-
if (file.exists) file else throw new FileNotFoundException(s"Could not locate [$jarName]. Tests require SBT 0.13+")
57-
}
52+
def findScalaJar(artifactId: String): File = findIvyJar("org.scala-lang", artifactId, scalaVersion)
5853

5954
def findIvyJar(groupId: String, artifactId: String, version: String): File = {
6055
val userHome = System.getProperty("user.home")
6156
val sbtHome = userHome + "/.ivy2"
6257
val jarPath = sbtHome + "/cache/" + groupId + "/" + artifactId + "/jars/" + artifactId + "-" + version + ".jar"
6358
val file = new File(jarPath)
64-
if (file.exists) file else throw new FileNotFoundException(s"Could not locate [$jarPath]. Tests require SBT 0.13+")
59+
if (file.exists) {
60+
println(s"Located ivy jar [$file]")
61+
file
62+
} else throw new FileNotFoundException(s"Could not locate [$jarPath]. Tests require SBT 0.13+")
6563
}
6664

6765
def sbtCompileDir: File = {
@@ -93,7 +91,7 @@ class ScoverageAwareCompiler(settings: scala.tools.nsc.Settings, reporter: scala
9391
val sources = new ListBuffer[String]
9492

9593
override val phaseName: String = "scoverage-teststore"
96-
override val runsAfter: List[String] = List("dce")
94+
override val runsAfter: List[String] = List("dce") // deadcode
9795
override val runsBefore = List[String]("terminal")
9896

9997
override protected def newTransformer(unit: global.CompilationUnit): global.Transformer = new Transformer(unit)

0 commit comments

Comments
 (0)