Skip to content

Commit e3e60b0

Browse files
Merge pull request #3871 from dotty-staging/fix-QuoteDriver-classpath
Fix classpath in QuoteDriver when executing from sbt
2 parents 7741f12 + 014164d commit e3e60b0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ package dotty.tools.dotc.quoted
33
import dotty.tools.dotc.ast.tpd
44
import dotty.tools.dotc.Driver
55
import dotty.tools.dotc.core.Contexts.Context
6-
import dotty.tools.dotc.core.StdNames._
76
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, VirtualDirectory}
87
import dotty.tools.repl.AbstractFileClassLoader
98
import dotty.tools.dotc.printing.DecompilerPrinter
109

1110
import scala.quoted.Expr
1211

12+
import java.net.URLClassLoader
13+
1314
class QuoteDriver extends Driver {
1415
import tpd._
1516

@@ -61,7 +62,15 @@ class QuoteDriver extends Driver {
6162

6263
override def initCtx: Context = {
6364
val ictx = super.initCtx.fresh
64-
val classpath = System.getProperty("java.class.path")
65+
var classpath = System.getProperty("java.class.path")
66+
this.getClass.getClassLoader match {
67+
case cl: URLClassLoader =>
68+
// Loads the classes loaded by this class loader
69+
// When executing `run` or `test` in sbt the classpath is not in the property java.class.path
70+
val newClasspath = cl.getURLs.map(_.getFile())
71+
classpath = newClasspath.mkString("", ":", if (classpath == "") "" else ":" + classpath)
72+
case _ =>
73+
}
6574
ictx.settings.classpath.update(classpath)(ictx)
6675
ictx
6776
}

0 commit comments

Comments
 (0)