summaryrefslogtreecommitdiff
path: root/scalaplugin
diff options
context:
space:
mode:
authorRoman Timushev <rtimush@gmail.com>2017-12-11 17:25:38 +0100
committerLi Haoyi <haoyi.sg@gmail.com>2017-12-11 08:25:38 -0800
commitbb61c05217671e80ba381b2cac869130c306baa8 (patch)
tree93a0ef6dcaa6f1e1b95251f26519ab92b31d078b /scalaplugin
parentf4b61e2a28a6eb537dda1136859e7a51429e8adf (diff)
downloadmill-bb61c05217671e80ba381b2cac869130c306baa8.tar.gz
mill-bb61c05217671e80ba381b2cac869130c306baa8.tar.bz2
mill-bb61c05217671e80ba381b2cac869130c306baa8.zip
Resolve compiler bridge jar (#45)
* Resolve compiler bridge jar * Create a release artifact
Diffstat (limited to 'scalaplugin')
-rw-r--r--scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala10
-rw-r--r--scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala24
2 files changed, 23 insertions, 11 deletions
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala b/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala
index 055b3206..21ecdca1 100644
--- a/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala
+++ b/scalaplugin/src/main/scala/mill/scalaplugin/Lib.scala
@@ -36,7 +36,7 @@ object Lib{
sources: Seq[Path],
compileClasspath: Seq[Path],
compilerClasspath: Seq[Path],
- compilerBridge: Seq[Path],
+ compilerBridge: Path,
scalacOptions: Seq[String],
scalacPluginClasspath: Seq[Path],
javacOptions: Seq[String],
@@ -52,10 +52,6 @@ object Lib{
}
val compilerJars = compilerClasspath.toArray.map(_.toIO)
- val compilerBridgeKey = "MILL_COMPILER_BRIDGE_"+scalaVersion.replace('.', '_')
- val compilerBridgePath = sys.props(compilerBridgeKey)
- assert(compilerBridgePath != null, "Cannot find compiler bridge " + compilerBridgeKey)
- val compilerBridgeJar = new java.io.File(compilerBridgePath)
val classloaderSig = compilerClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum
@@ -123,7 +119,7 @@ object Lib{
scalaInstance,
ClasspathOptionsUtil.boot,
None,
- ZincUtil.scalaCompiler(scalaInstance, compilerBridgeJar)
+ ZincUtil.scalaCompiler(scalaInstance, compilerBridge.toIO)
),
setup = ic.setup(
lookup,
@@ -186,6 +182,8 @@ object Lib{
def scalaRuntimeIvyDeps(scalaVersion: String) = Seq[Dep](
Dep.Java("org.scala-lang", "scala-library", scalaVersion)
)
+ def compilerBridgeIvyDep(scalaVersion: String) =
+ Dep.Point(coursier.Dependency(coursier.Module("com.lihaoyi", "mill-bridge"), "0.1-SNAPSHOT", transitive = false))
val DefaultShellScript: Seq[String] = Seq(
"#!/usr/bin/env sh",
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
index 8167a4f1..f7db3006 100644
--- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
+++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
@@ -129,10 +129,24 @@ trait ScalaModule extends Module with TaskModule{ outer =>
/**
* Strange compiler-bridge jar that the Zinc incremental compile needs
*/
- def compilerBridgeClasspath: T[Seq[PathRef]] = T{
- resolveDeps(
- T.task{Seq(Dep("org.scala-sbt", "compiler-bridge", "1.0.5"))},
- )()
+ def compilerBridge: T[PathRef] = T{
+ val compilerBridgeKey = "MILL_COMPILER_BRIDGE_" + scalaVersion().replace('.', '_')
+ val compilerBridgePath = sys.props(compilerBridgeKey)
+ if (compilerBridgePath != null) PathRef(Path(compilerBridgePath), quick = true)
+ else {
+ val dep = compilerBridgeIvyDep(scalaVersion())
+ val classpath = resolveDependencies(
+ repositories,
+ scalaVersion(),
+ scalaBinaryVersion(),
+ Seq(dep)
+ )
+ classpath match {
+ case Seq(single) => PathRef(single.path, quick = true)
+ case Seq() => throw new Exception(dep + " resolution failed")
+ case _ => throw new Exception(dep + " resolution resulted in more than one file")
+ }
+ }
}
def scalacPluginClasspath: T[Seq[PathRef]] =
@@ -171,7 +185,7 @@ trait ScalaModule extends Module with TaskModule{ outer =>
allSources().map(_.path),
compileDepClasspath().map(_.path),
scalaCompilerClasspath().map(_.path),
- compilerBridgeClasspath().map(_.path),
+ compilerBridge().path,
scalacOptions(),
scalacPluginClasspath().map(_.path),
javacOptions(),