如何使用Gradle配置Dokka的软件包文档?

问题描述 投票:0回答:1

如果不使用从文件系统根目录开始的完整绝对路径,则无法配置Dokka以包括我的软件包的文档。我的Gradle文件中有问题(includes行有问题):

dokka {
    outputFormat = 'html'
    outputDirectory = "$projectDir/../doc"


    configuration {
        // Use to include or exclude non public members.
        includeNonPublic = false

        // Do not output deprecated members. Applies globally, can be overridden by packageOptions
        skipDeprecated = false

        // Emit warnings about not documented members. Applies globally, also can be overridden by packageOptions
        reportUndocumented = true

        // Do not create index pages for empty packages
        skipEmptyPackages = true

        includes = ["${projectDir}/app/src/main/kotlin/com/biexpertise/simplewebview/packages.md"]
    }
}

[如果发生此错误,我将运行./gradlew dokka

> Task :app:dokka FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:dokka'.
> org.codehaus.groovy.runtime.GStringImpl cannot be cast to java.lang.String

如果删除$projectDir并使用绝对路径,则说明一切正常。是否可以使用相对路径?

gradle kotlin-dokka
1个回答
0
投票

因此,这实际上是dokka的Gradle插件的问题,或更具体地说,是Groovy String实现的问题。 Groovy将其自己的GStringImpl用于字符串,而不是String类,这在将List<GStringImpl>强制转换为List<String>时会导致问题(此强制转换不成功)。

最简单的解决方案是在包含文件中调用.toString(),如下所示:

includes = ["${projectDir}/app/src/main/kotlin/com/biexpertise/simplewebview/packages.md".toString()]

尽管应该在dokka上解决,但是您可以在GitHub上提交错误报告

© www.soinside.com 2019 - 2024. All rights reserved.