Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new dotty version #569

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions scalalib/worker/src/ZincWorkerImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,30 @@ class ZincWorkerImpl(compilerBridge: Either[

val sourceFolder = mill.api.IO.unpackZip(srcJars(scalaVersion, scalaOrganization))(workingDir)
val classloader = mill.api.ClassLoader.create(compilerJars.map(_.toURI.toURL), null)(ctx0)
val compilerMain = classloader.loadClass(
if (isDotty(scalaVersion)) "dotty.tools.dotc.Main"
else "scala.tools.nsc.Main"
)

val sources = os.walk(sourceFolder.path).filter(a => a.ext == "scala" || a.ext == "java")

val argsArray = Array[String](
"-d", compiledDest.toString,
"-classpath", (compilerJars ++ compilerBridgeClasspath).mkString(File.pathSeparator)
) ++ os.walk(sourceFolder.path).filter(_.ext == "scala").map(_.toString)
) ++ sources.map(_.toString)

val allScala = sources.forall(_.ext == "scala")
val allJava = sources.forall(_.ext == "java")
if (allJava) {
import scala.sys.process._
(Seq("javac") ++ argsArray).!
} else if (allScala) {
val compilerMain = classloader.loadClass(
if (isDotty(scalaVersion)) "dotty.tools.dotc.Main"
else "scala.tools.nsc.Main"
)
compilerMain.getMethod("process", classOf[Array[String]])
.invoke(null, argsArray)
} else {
throw new IllegalArgumentException("Currently not implemented case.")
}

compilerMain.getMethod("process", classOf[Array[String]])
.invoke(null, argsArray)
}
compiledDest
}
Expand Down