Skip to content

Commit

Permalink
Fix com-lihaoyi#282 by passing plugins as arguments to scaladoc
Browse files Browse the repository at this point in the history
Plus a couple tests to sanity check.
  • Loading branch information
julianmichael committed Apr 7, 2018
1 parent cfb4944 commit 8dce375
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scalalib/src/mill/scalalib/ScalaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import monocle.macros._
@Lenses case class Foo(bar: String)
object Main extends App {
println(Foo.bar.get(Foo("bar")))
}
32 changes: 32 additions & 0 deletions scalalib/test/src/mill/scalalib/HelloWorldTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down Expand Up @@ -475,6 +489,24 @@ 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)
}
}
}


Expand Down

0 comments on commit 8dce375

Please # to comment.