[英]Disable sbt subproject doc generation
I have a multi-project Scala build in SBT, in which I have a root project that effectively just aggregates two subprojects: a macro library and a core library that uses that macro library. 我在SBT中有一个多项目Scala构建,其中有一个根项目,该根项目实际上只是聚合了两个子项目:一个宏库和一个使用该宏库的核心库。
I'm using the excellent sbt-unidoc
plugin to create a single, unified scaladoc
API for the entire library (macro + core combined). 我正在使用出色的
sbt-unidoc
插件为整个库(宏+核心结合)创建一个统一的scaladoc
API。
Unfortunately, sbt-unidoc
has some limitations. 不幸的是,
sbt-unidoc
有一些限制。 For instance, by default, it does not hook into the doc
task, and its output is placed in the target directory's unidoc
folder, instead of the api
folder. 例如,默认情况下,它不挂接到
doc
任务,并且其输出放置在目标目录的unidoc
文件夹中,而不是api
文件夹中。 Combined, these prevent the resulting documentation from being generated and packaged when executing the publish
or publishLocal
commands. 结合起来,它们会阻止在执行
publish
或publishLocal
命令时生成和打包结果文档。 Fortunately (and thanks to an issue raised by inkytonic
on the sbt-unidoc
GitHub site), there's a simple solution to this: 幸运的是(并且感谢
inkytonic
在sbt-unidoc
GitHub网站上提出的问题 ),对此有一个简单的解决方案:
lazy val customUnidocSettings = unidocSettings ++ Seq (
doc in Compile := (doc in ScalaUnidoc).value,
target in unidoc in ScalaUnidoc := crossTarget.value / "api"
)
These settings are then employed in the root project: 然后,将这些设置用于根项目:
lazy val macro = (project in file ("macro")).
settings (
name = "foo-macro"
)
lazy val core = (project in file ("core")).
settings (
name = "foo-core"
).
dependsOn (macro)
lazy val root = (project in file (".")).
settings (customUnidocSettings: _*).
settings (
name = "foo"
).
aggregate (macro, core)
Now, if you execute the sbt tasks doc
, publish
, publishLocal
, etc. the root
project will generate unified documentation for the two subprojects and that unified documentation is packaged during publication. 现在,如果您执行sbt任务
doc
, publish
, publishLocal
等,则root
项目将为两个子项目生成统一的文档,并且该统一的文档在发布过程中打包publishLocal
。
Unfortunately, these same commands also attempt to generate individual subproject API documentation for both the macro
and core
subprojects - and, for a variety of reasons in my particular case, these will fail. 不幸的是,这些相同的命令还试图为
macro
子项目和core
子项目生成单独的子项目API文档-并且,由于各种原因,在我的特殊情况下,这些命令将失败。 Not to mention that it takes time to generate the documentation twice. 更不用说两次生成文档都需要时间。
So, here's my question: is there any simple way to disable the doc
task for each subproject? 所以,这是我的问题:是否有任何简单的方法可以为每个子项目禁用
doc
任务?
The only approach I've been able to discover so far is to trick doc
into thinking that there are no files with embedded Scaladoc. 我已经能够到目前为止发现的唯一方法就是欺骗
doc
,以为有嵌入Scaladoc没有文件。 This works, but it's a fudge rather than a real solution: 这行得通,但这只是一个软糖,而不是一个真正的解决方案:
lazy val noDocFileSettings = Seq (
sources in doc in Compile := List()
)
lazy val macro = (project in file ("macro")).
settings (noDocFileSettings: _*).
settings (
name = "foo-macro"
)
lazy val core = (project in file ("core")).
settings (noDocFileSettings: _*).
settings (
name = "foo-core"
).
dependsOn (macro)
Any suggestions? 有什么建议么?
You can say exactly what you want to aggregate . 您可以确切地说出要汇总的内容 。 In this case
在这种情况下
lazy val root = (project in file (".")).
settings (customUnidocSettings: _*).
settings (
name = "foo",
aggregate in doc := false
).
aggregate (macro, core)
should work, I believe. 我相信应该会奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.