Open jroper opened 8 years ago
Actually, I just had a look at the genjavadoc plugin - it does a separate invocation of scalac to run, so it's not run as part of a normal compile. So it seems Akka needlessly disables it. Though, plugging into scaladoc rather than scalac would still be interesting, as it would mean doing a full build including java/scala docs for a project would only invoke the scala compiler twice, rather than 3 times.
Well, I was wrong about genjavadoc plugin doing a separate invocation of scalac, but here's the configuration required to make it do a separate invocation of scalac:
object Unidoc extends AutoPlugin {
lazy val GenjavadocCompilerPlugin = config("genjavadocplugin") hide
override def trigger = allRequirements
override def requires = plugins.JvmPlugin
override def projectConfigurations: Seq[Configuration] = Seq(Genjavadoc)
override lazy val projectSettings = inConfig(Genjavadoc)(Defaults.configSettings) ++ Seq(
ivyConfigurations += GenjavadocCompilerPlugin,
libraryDependencies += "com.typesafe.genjavadoc" %% "genjavadoc-plugin" % "0.9" % "genjavadocplugin->default(compile)" cross CrossVersion.full,
scalacOptions in Genjavadoc ++= Seq(
"-P:genjavadoc:out=" + (target.value / "java"),
"-P:genjavadoc:fabricateParams=false"
),
scalacOptions in Genjavadoc ++=
update.value.matching(configurationFilter(GenjavadocCompilerPlugin.name)).filter(_.getName.contains("genjavadoc"))
.map("-Xplugin:" + _.getAbsolutePath),
sources in Genjavadoc := (sources in Compile).value,
dependencyClasspath in Genjavadoc := (dependencyClasspath in Compile).value
)
}
Using the above, javadocs are only evaluated by genjavadoc:compile
, not by compile
.
Most of the code there is actually working around the fact that genjavadoc does not support an enabled flag, so that it can be disabled in compile and test. Instead, we have to manually add the plugin to just the Genjavadoc scope, instead of using sbt's built in auto compiler plugin support.
I don't know if this is possible, but given the overhead of running
genjavadoc
on every compile (which I don't know much about, but it's enough to warrant the Akka team having it turned off by default), then it seems plugging in to scalac is not the right thing to do. Rather, it would make a lot more sense to plug into scaladoc, because your most likely to want to generate the javadoc when you run scaladac. Theoretically, since scaladoc uses scalac, this should be possible.