如何在doc任务中排除java源文件? [英] How to exclude java source files in doc task?
问题描述
我将 sbt 0.11.2 用于混合 Java/Scala 项目.我意识到当我从 sbt 中运行 doc
命令时,它不仅为 src/main/scala
中的 Scala 源文件创建了 scaladoc,而且对于 src/main/java
中的 Java 源文件(sbt wiki 声称为 src/main/scala
创建它们只是这似乎不是真的).
I'm using sbt 0.11.2 for a mixed Java/Scala project. I've realized that when I run the doc
command from within sbt, it does not only create the scaladocs for the Scala source files in src/main/scala
, but also for the Java source files in src/main/java
(the sbt wiki claims to create them for src/main/scala
only that seems not true).
然而,这看起来不太好.例如,对于带有静态方法的名为 Foo
的 Java 类,在生成的 scaladoc 中有两个条目:一个 Foo
类和一个 Foo
对象.类只列出构造函数,对象列出静态方法.
However, this does not look very well. For instance, for a Java class named Foo
with static methods there are two entries in the generated scaladoc: a Foo
class and a Foo
object. The class only lists the constructor and the object lists the static methods.
有什么办法可以告诉 sbt 从 scaladoc 生成中排除 src/main/java
文件夹吗?我想为它们创建 javadoc.
Is there any way I can tell sbt to exclude the src/main/java
folder from the scaladoc generation? I want to create javadocs for those instead.
推荐答案
通常的处理方式是使用 inspect
来查看信息来自哪里,然后对其进行更改.检查 doc
显示 compile:sources(for doc)
,这是一个 Seq[java.io.File]
,可以像这样改变这个:
The usual way to handle that is to use inspect
to see where the information is coming from, and then change it. Inspecting at doc
shows compile:sources(for doc)
, which is a Seq[java.io.File]
, and can be changed like this:
sources in (Compile, doc) ~= (_ filter (_.getName endsWith ".scala"))
您可以使用 show compile:sources(for doc)
查看它包含的内容,然后使用 set
更改它并再次检查其值.
You can use show compile:sources(for doc)
to see what it contains, and then set
to change it and check again its value.
这篇关于如何在doc任务中排除java源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!