diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala index 816e2077c5c..b98f248e229 100644 --- a/scalalib/src/mill/scalalib/ScalaModule.scala +++ b/scalalib/src/mill/scalalib/ScalaModule.scala @@ -129,7 +129,8 @@ trait ScalaModule extends JavaModule { outer => if p.isFile } yield p.toNIO.toString - val options = Seq("-d", javadocDir.toNIO.toString, "-usejavacp") + val pluginOptions = scalacPluginClasspath().map(pluginPathRef => s"-Xplugin:${pluginPathRef.path}") + val options = Seq("-d", javadocDir.toNIO.toString, "-usejavacp") ++ pluginOptions if (files.nonEmpty) subprocess( "scala.tools.nsc.ScalaDoc", diff --git a/scalalib/test/resources/hello-world-macros/core/src/Main.scala b/scalalib/test/resources/hello-world-macros/core/src/Main.scala new file mode 100644 index 00000000000..20924a60d24 --- /dev/null +++ b/scalalib/test/resources/hello-world-macros/core/src/Main.scala @@ -0,0 +1,5 @@ +import monocle.macros._ +@Lenses case class Foo(bar: String) +object Main extends App { + println(Foo.bar.get(Foo("bar"))) +} diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala index 215897669b5..597f9f67a1b 100644 --- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala +++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala @@ -116,6 +116,20 @@ object HelloWorldTests extends TestSuite { ) } } + + object HelloWorldMacros extends HelloBase{ + object core extends ScalaModule { + def scalaVersion = "2.11.8" + + def ivyDeps = Agg( + ivy"com.github.julien-truffaut::monocle-macro::1.4.0" + ) + def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg( + ivy"org.scalamacros:::paradise:2.1.0" + ) + } + } + val resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world" def jarMainClass(jar: JarFile): Option[String] = { @@ -475,5 +489,23 @@ object HelloWorldTests extends TestSuite { ) } } + 'macros - { + // make sure macros are applied when compiling/running + 'runMain - workspaceTest( + HelloWorldMacros, + resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-macros" + ){ eval => + val Right((_, evalCount)) = eval.apply(HelloWorldMacros.core.runMain("Main")) + assert(evalCount > 0) + } + // make sure macros are applied when compiling during scaladoc generation + 'docJar - workspaceTest( + HelloWorldMacros, + resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-macros" + ){ eval => + val Right((_, evalCount)) = eval.apply(HelloWorldMacros.core.docJar) + assert(evalCount > 0) + } + } } }