com-lihaoyi/mill

Macro expansion seems to fail when running Scaladoc

julianmichael opened this issue · 1 comments

Related to #275 (awesome fix by the way, thank you!) — macros seem to be expanded properly when executing compile, run, or console, but scaladoc is complaining about them being missing. This also causes e.g. publishLocal to fail since it relies on docJar. Minimal example:
build.sc:

import mill._, mill.scalalib._

object foo 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"
  )

  override def mainClass = Some("Main")
}

foo/src/Main.scala:

import monocle.macros._
@Lenses case class Foo(bar: String)
object Main {
  final def main(args: Array[String]): Unit = {
    println(Foo.bar.get(Foo("bar")))
  }
}

Running mill foo.run prints out bar as expected. However, mill foo.docJar produces:

[15/15] foo.docJar 
/Users/julian/Documents/scratch/test/foo/src/Main.scala:5: error: value bar is not a member of object Foo
    println(Foo.bar.get(Foo("bar")))
                ^
model contains 3 documentable templates
one error found
1 targets failed
foo.docJar ammonite.ops.InteractiveShelloutException
    mill.modules.Jvm$.subprocess(Jvm.scala:180)
    mill.scalalib.ScalaModule.$anonfun$docJar$2(ScalaModule.scala:226)
    mill.scalalib.ScalaModule$$Lambda$2307/1935861231.apply(Unknown Source)
    mill.define.ApplyerGenerated.$anonfun$zipMap$2(ApplicativeGenerated.scala:7)
    mill.define.ApplyerGenerated$$Lambda$2232/2014319819.apply(Unknown Source)
    mill.define.Task$MappedDest.evaluate(Task.scala:348)

The failure is being thrown during the Scaladoc subprocess call in docJar. I tried adding scalacPluginClasspath().map(_.path) to the classpath in the subprocess call but the problem remained.

@julianmichael can you try passing in the flag to enable plugins as described https://stackoverflow.com/a/24762769/871202