sbt-unidoc -- 如何从 RootProject 中排除子模块 [英] sbt-unidoc -- how to exclude a sub-module from a RootProject

查看:29
本文介绍了sbt-unidoc -- 如何从 RootProject 中排除子模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 sbt-unidoc 插件构建复合 API 文档.我使用 sbt 的 RootProject 构造函数和 URI 链接到 GitHub 上的各种项目.

I am building compound API docs using the sbt-unidoc plugin. I am linking to various projects on GitHub using sbt's RootProject constructor with URIs.

其中一个项目具有互斥的子项目:

One of these projects has mutually exclusive sub-projects:

val foo = RootProject(uri("git://github.com/Foo/Bar.git#v1.0.0"))

即在这个项目foo中,有两个子模块foo-db1foo-db2,它们包含相同的类型,但是针对不同的依赖构建库版本.

That is, in this project foo, there are two sub-modules foo-db1 and foo-db2, which contain the same types but are built against different dependency library versions.

现在,当我尝试运行 unidoc 时,它失败了,因为从 unidoc 的角度来看,一个类型被定义了两次.从文档中,我可以看到有一个过滤功能:

Now when I try to run unidoc, it fails because a type is defined twice from unidoc's perspective. From the documentation, I can see there is a filter function:

unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject -- inProjects(app)

但是如何从我的 RootProject 为子模块创建标识符?换句话说,我将如何做到这一点:

But how do I create an identifier for a sub-module from my RootProject? In other words, how would I do this:

unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject --
  inProjects(foo).SELECT_SUB_PROJECT(foo-v1)

?

推荐答案

答案在 此项:不是使用 RootProject,而是创建了许多 ProjectRef 实例.

The answer is found in this entry: Instead of using RootProject, one creates a number of ProjectRef instances.

import UnidocKeys._

val fooURI = uri("git://github.com/Foo/Bar.git#v1.0.0")
val fooDb1 = ProjectRef(fooURI, "foo-db1") // sub-module I don't want
val fooDb2 = ProjectRef(fooURI, "foo-db2") // sub-module I want

val root = (project in file("."))
  .settings( ... )
  .settings(unidocSettings: _*)
  .settings(site.settings ++ ghpages.settings: _*)
  .settings(
    unidocProjectFilter in (ScalaUnidoc, unidoc) := 
      inAnyProject -- inProjects(fooDb1)
  )
  .aggregate(fooDb2)

请注意,只将 fooDb2 放在聚合中而将 fooDb1 放在外面,没有任何效果.似乎 unidoc 总是包含所有子模块,无论如何,所以必须使用 unidocProjectFilter 来明确删除项目,即使它们没有出现在聚合中.

Note that putting only fooDb2 in the aggregate and leaving fooDb1 out, does not have any effect. It seems that unidoc always includes all sub-modules, no matter, so one has to use the unidocProjectFilter to explicitly remove projects, even if they don't appear in the aggregate.

这篇关于sbt-unidoc -- 如何从 RootProject 中排除子模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆