Skip to content

Commit

Permalink
Allow usage of ZincWorkerImpl without hashing files (#525)
Browse files Browse the repository at this point in the history
* Allow usage of ZincWorkerImpl without hashing files

This is to better support non-Mill build tools like Bazel or Make who might do their own file hashing/mtiming for change-detection

* Update ZincWorkerImpl.scala

* Update ZincWorkerImpl.scala

* Update ZincWorkerImpl.scala
  • Loading branch information
lihaoyi-databricks authored and lihaoyi committed Jan 10, 2019
1 parent eb497a8 commit 4506537
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions scalalib/worker/src/ZincWorkerImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ class ZincWorkerImpl(compilerBridge: Either[
compileClasspath: Agg[os.Path],
javacOptions: Seq[String])
(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = {

for(res <- compileJava0(
upstreamCompileOutput,
sources,
compileClasspath,
javacOptions
)) yield CompilationResult(res._1, PathRef(res._2))
}
def compileJava0(upstreamCompileOutput: Seq[CompilationResult],
sources: Agg[os.Path],
compileClasspath: Agg[os.Path],
javacOptions: Seq[String])
(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[(os.Path, os.Path)] = {
compileInternal(
upstreamCompileOutput,
sources,
Expand All @@ -141,6 +154,30 @@ class ZincWorkerImpl(compilerBridge: Either[
compilerClasspath: Agg[os.Path],
scalacPluginClasspath: Agg[os.Path])
(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = {

for (res <- compileMixed0(
upstreamCompileOutput,
sources,
compileClasspath,
javacOptions,
scalaVersion,
scalaOrganization,
scalacOptions,
compilerClasspath,
scalacPluginClasspath
)) yield CompilationResult(res._1, PathRef(res._2))
}

def compileMixed0(upstreamCompileOutput: Seq[CompilationResult],
sources: Agg[os.Path],
compileClasspath: Agg[os.Path],
javacOptions: Seq[String],
scalaVersion: String,
scalaOrganization: String,
scalacOptions: Seq[String],
compilerClasspath: Agg[os.Path],
scalacPluginClasspath: Agg[os.Path])
(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[(os.Path, os.Path)] = {
withCompilers(
scalaVersion,
scalaOrganization,
Expand Down Expand Up @@ -208,7 +245,7 @@ class ZincWorkerImpl(compilerBridge: Either[
javacOptions: Seq[String],
scalacOptions: Seq[String],
compilers: Compilers)
(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[CompilationResult] = {
(implicit ctx: ZincWorkerApi.Ctx): mill.api.Result[(os.Path, os.Path)] = {
os.makeDir.all(ctx.dest)

val logger = {
Expand Down Expand Up @@ -281,7 +318,7 @@ class ZincWorkerImpl(compilerBridge: Either[
)
)

mill.api.Result.Success(CompilationResult(zincFile, PathRef(classesDir)))
mill.api.Result.Success((zincFile, classesDir))
}catch{case e: CompileFailed => mill.api.Result.Failure(e.toString)}
}
}

0 comments on commit 4506537

Please sign in to comment.