From a583f70966c6d5b0fbda0c9989803220b7292ac9 Mon Sep 17 00:00:00 2001 From: Tin Pavlinic Date: Fri, 8 Dec 2017 12:03:51 +1100 Subject: Add support for compiler plugins and enable acyclic plugin in build --- .../src/main/scala/mill/scalaplugin/ScalaModule.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scalaplugin/src') diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index 4de2f416..802a881a 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -42,6 +42,7 @@ object ScalaModule{ compilerClasspath: Seq[Path], compilerBridge: Seq[Path], scalacOptions: Seq[String], + scalacPluginClasspath: Seq[Path], javacOptions: Seq[String], upstreamCompileOutput: Seq[CompilationResult]) (implicit ctx: Ctx): CompilationResult = { @@ -117,7 +118,7 @@ object ScalaModule{ classpath = classesIODir +: compileClasspathFiles, sources = sources.flatMap(ls.rec).filter(x => x.isFile && x.ext == "scala").map(_.toIO).toArray, classesDirectory = classesIODir, - scalacOptions = scalacOptions.toArray, + scalacOptions = (scalacPluginClasspath.map(jar => s"-Xplugin:${jar}") ++ scalacOptions).toArray, javacOptions = javacOptions.toArray, maxErrors = 10, sourcePositionMappers = Array(), @@ -247,6 +248,7 @@ trait ScalaModule extends Module with TaskModule{ outer => def scalaBinaryVersion = T{ scalaVersion().split('.').dropRight(1).mkString(".") } def ivyDeps = T{ Seq[Dep]() } def compileIvyDeps = T{ Seq[Dep]() } + def scalacPluginIvyDeps = T{ Seq[Dep]() } def runIvyDeps = T{ Seq[Dep]() } def basePath: Path @@ -320,13 +322,18 @@ trait ScalaModule extends Module with TaskModule{ outer => )() } + def scalacPluginClasspath: T[Seq[PathRef]] = + resolveDeps( + T.task{scalacPluginIvyDeps()} + )() + /** * Classpath of the Scala Compiler & any compiler plugins */ def scalaCompilerClasspath: T[Seq[PathRef]] = T{ resolveDeps( T.task{scalaCompilerIvyDeps(scalaVersion()) ++ scalaRuntimeIvyDeps(scalaVersion())}, - )() + )() ++ scalacPluginClasspath() } /** @@ -353,6 +360,7 @@ trait ScalaModule extends Module with TaskModule{ outer => scalaCompilerClasspath().map(_.path), compilerBridgeClasspath().map(_.path), scalacOptions(), + scalacPluginClasspath().map(_.path), javacOptions(), upstreamCompileOutput() ) -- cgit v1.2.3