Skip to content

Macro expansion seems to fail when running Scaladoc #282

Closed
@julianmichael

Description

@julianmichael

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions