Skip to content

Commit 3eb6235

Browse files
julianmichaellihaoyi
authored andcommitted
Fix #282 by passing plugins as arguments to scaladoc
Plus a couple tests to sanity check.
1 parent f0e7dce commit 3eb6235

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

scalalib/src/mill/scalalib/ScalaModule.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ trait ScalaModule extends JavaModule { outer =>
129129
if p.isFile
130130
} yield p.toNIO.toString
131131

132-
val options = Seq("-d", javadocDir.toNIO.toString, "-usejavacp")
132+
val pluginOptions = scalacPluginClasspath().map(pluginPathRef => s"-Xplugin:${pluginPathRef.path}")
133+
val options = Seq("-d", javadocDir.toNIO.toString, "-usejavacp") ++ pluginOptions
133134

134135
if (files.nonEmpty) subprocess(
135136
"scala.tools.nsc.ScalaDoc",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import monocle.macros._
2+
@Lenses case class Foo(bar: String)
3+
object Main extends App {
4+
println(Foo.bar.get(Foo("bar")))
5+
}

scalalib/test/src/mill/scalalib/HelloWorldTests.scala

+32
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,20 @@ object HelloWorldTests extends TestSuite {
116116
)
117117
}
118118
}
119+
120+
object HelloWorldMacros extends HelloBase{
121+
object core extends ScalaModule {
122+
def scalaVersion = "2.11.8"
123+
124+
def ivyDeps = Agg(
125+
ivy"com.github.julien-truffaut::monocle-macro::1.4.0"
126+
)
127+
def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg(
128+
ivy"org.scalamacros:::paradise:2.1.0"
129+
)
130+
}
131+
}
132+
119133
val resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world"
120134

121135
def jarMainClass(jar: JarFile): Option[String] = {
@@ -475,5 +489,23 @@ object HelloWorldTests extends TestSuite {
475489
)
476490
}
477491
}
492+
'macros - {
493+
// make sure macros are applied when compiling/running
494+
'runMain - workspaceTest(
495+
HelloWorldMacros,
496+
resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-macros"
497+
){ eval =>
498+
val Right((_, evalCount)) = eval.apply(HelloWorldMacros.core.runMain("Main"))
499+
assert(evalCount > 0)
500+
}
501+
// make sure macros are applied when compiling during scaladoc generation
502+
'docJar - workspaceTest(
503+
HelloWorldMacros,
504+
resourcePath = pwd / 'scalalib / 'test / 'resources / "hello-world-macros"
505+
){ eval =>
506+
val Right((_, evalCount)) = eval.apply(HelloWorldMacros.core.docJar)
507+
assert(evalCount > 0)
508+
}
509+
}
478510
}
479511
}

0 commit comments

Comments
 (0)