From 3d5cb7bdbac7f6aa5e688308e4cc1ca968125778 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Mon, 24 Jan 2022 09:47:26 +0100 Subject: [PATCH 1/2] Added section about plugin usage in Mill --- _overviews/plugins/index.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/_overviews/plugins/index.md b/_overviews/plugins/index.md index 20b3508cf9..a24024946c 100644 --- a/_overviews/plugins/index.md +++ b/_overviews/plugins/index.md @@ -243,6 +243,38 @@ For more details, see [Compiler Plugin Support](https://www.scala-sbt.org/1.x/docs/Compiler-Plugins.html) in the sbt manual. +## Using your plugin in Mill + +To use a scalac compiler plugin in your Mill project, you can override +the `scalacPluginIvyDeps` target to add your plugins dependency coordinates. + +Plugin options can be specified in `scalacOptions`. + +Example: + +```scala +// build.sc +import mill._, mill.scalalib._ + +object foo extends ScalaModule { + // Add the compiler plugin divbyzero in version 1.0 + def scalacPluginIvyDeps = Agg(ivy"org.divbyzero:::"divbyzero:1.0") + // Enable the `verbose` option of the divbyzero plugin + def scalacOptions = Seq("-P:divbyzero:verbose:true") + // other settings + // ... +} + +``` + +Please notice, that compiler plugins are typically bound to the full +version of the compiler, hence you have to use the `:::` (instead of +normal `::`) between the organization and the artifact name, +to declare your dependency. + +For more information about plugin usage in Mill, please refer to the +[Mill documentation](https://com-lihaoyi.github.io/mill/mill/Configuring_Mill.html#_scala_compiler_plugins). + ## Developing compiler plugins with an IDE Internally, the use of path-dependent types in the Scala compiler From 666fe8a1feca180f3ea3ded579ebae11f59461dd Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Mon, 24 Jan 2022 10:13:51 +0100 Subject: [PATCH 2/2] Update _overviews/plugins/index.md Co-authored-by: Julien Richard-Foy --- _overviews/plugins/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_overviews/plugins/index.md b/_overviews/plugins/index.md index a24024946c..c28e441f08 100644 --- a/_overviews/plugins/index.md +++ b/_overviews/plugins/index.md @@ -258,7 +258,7 @@ import mill._, mill.scalalib._ object foo extends ScalaModule { // Add the compiler plugin divbyzero in version 1.0 - def scalacPluginIvyDeps = Agg(ivy"org.divbyzero:::"divbyzero:1.0") + def scalacPluginIvyDeps = Agg(ivy"org.divbyzero:::divbyzero:1.0") // Enable the `verbose` option of the divbyzero plugin def scalacOptions = Seq("-P:divbyzero:verbose:true") // other settings