Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro expansion seems to fail when running Scaladoc #282

Closed
julianmichael opened this issue Apr 7, 2018 · 1 comment
Closed

Macro expansion seems to fail when running Scaladoc #282

julianmichael opened this issue Apr 7, 2018 · 1 comment

Comments

@julianmichael
Copy link
Contributor

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.

@lihaoyi
Copy link
Member

lihaoyi commented Apr 7, 2018

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

julianmichael added a commit to julianmichael/mill that referenced this issue Apr 7, 2018
julianmichael added a commit to julianmichael/mill that referenced this issue Apr 8, 2018
@lihaoyi lihaoyi closed this as completed in 3eb6235 Apr 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants