您如何在Jitpack上使用maven为Kotlin库发布KDoc? [英] How do you publish KDoc for a Kotlin library using maven on Jitpack?
问题描述
经过大量研究和尝试,并寻求帮助,我已经在Jitpack上使用maven成功发布了私有的Github存储库(写为
After a lot of researching and trying out, and also asking for help, I've succeeded publishing a private Github repository using maven on Jitpack (written here).
所以,目前我放在Jitpack存储库中的文件就是这些:
So, currently the files that I put on the repository for Jitpack are just these:
- jitpack.yml-告诉要使用的文件
- library-release.aar-(混淆的)代码本身
- pom-default.xml-依赖关系和其他一些配置.
虽然依赖关系问题和AAR文件本身都可以使用,但我可以使用该库,但是我注意到,我找不到一种向使用该文件的人提供以KDoc(例如JavaDocs,但是Kotlin)编写的方法它.
While dependencies issues and the AAR file itself are fine and I can use the library, I've noticed I can't find a way to offer what I wrote there as KDoc (like JavaDocs, but for Kotlin) to whoever uses it.
除了执行各种gradle任务外,我还尝试了Android Studio本身的简单操作来生成它.由于没有提及KDoc,因此我改用 Tools
-> Generate JavaDocs
.
Besides the various gradle tasks, I've also tried the simple operation of Android Studio itself to produce it. Since there is no mention of KDoc, I used Tools
->Generate JavaDocs
instead.
可悲的是,它告诉我没有任何内容,实际上是在 此处报道的.strong> .
Sadly, it told me there are none, and indeed it was reported here.
但是,即使它确实成功了,我也不知道如何将其与其余文件一起发布.
But even if it did succeed, I wouldn't have known how to publish it together with the rest of the files.
我希望有可能,但是如何在Jitpack上使用maven生成和公开KDoc?
I hope it's possible, but how can I generate&public KDoc using maven on Jitpack?
推荐答案
您需要使用Dokka自动记录Kotlin项目.您可以在此上找到Dokka的简要说明.文章,并在需要时阅读文档.
You need to use Dokka for auto documenting Kotlin project. You can find a brief explanation of Dokka on this article and also read the documentation if required.
使用Gradle插件
首选方式是使用插件块.
Using the Gradle plugin
The preferred way is to use plugins block.
build.gradle.kts:
plugins {
id("org.jetbrains.dokka") version "1.4.32" }
repositories {
mavenCentral() }
该插件添加了 dokkaHtml
, dokkaJavadoc
, dokkaGfm
和 dokkaJekyll
项目任务.
The plugin adds dokkaHtml
, dokkaJavadoc
, dokkaGfm
and dokkaJekyll
tasks to the project.
正在应用插件
Dokka插件为每种输出格式创建Gradle配置
dokka $ {format}插件
的形式:
dependencies {
dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.4.32") }
您还可以创建自定义Dokka任务并直接添加插件内部:
You can also create a custom Dokka task and add plugins directly inside:
val customDokkaTask by creating(DokkaTask::class) {
dependencies {
plugins("org.jetbrains.dokka:kotlin-as-java-plugin:1.4.32")
} }
请注意,dokkaJavadoc任务只能正确记录单个文档jvm来源集
Please note that dokkaJavadoc task will properly document only single jvm source set
要生成文档,请使用适当的dokka $ {format}Gradle任务:
To generate the documentation, use the appropriate dokka${format} Gradle task:
./gradlew dokkaHtml
有关示例,请参阅Dokka Gradle示例项目.
Please see the Dokka Gradle example project for an example.
确保在 com.android.library
之后应用Dokka,然后 kotlin-android
.
Make sure you apply Dokka after com.android.library
and
kotlin-android
.
buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}")
} } repositories {
mavenCentral() } apply(plugin= "com.android.library") apply(plugin= "kotlin-android") apply(plugin= "org.jetbrains.dokka")
dokkaHtml.configure {
dokkaSourceSets {
named("main") {
noAndroidSdkLink.set(false)
}
} }
更多有关GitHub官方仓库的信息- https://github.com/Kotlin/dokka 您可能会喜欢本文作为好吧.
More at official GitHub repo - https://github.com/Kotlin/dokka You may like this article as well.
这篇关于您如何在Jitpack上使用maven为Kotlin库发布KDoc?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!