我有一个KotlinJVM库,我通过maven存储库将其作为.jar工件分发。我想为它提供一些Kdocs,以便它可以通过IntelliJ Idea的快速文档工具(ctrl+q)使用。我用dokka gradle插件生成html文档,用maven-publish插件分发我的工件。
下面是我的build.gradle.kts文件的内容:
import java.util.*
plugins {
kotlin("jvm") version "1.8.0"
id("org.jetbrains.dokka") version "1.8.10"
`maven-publish`
}
group = "com.example"
version = "1.0"
fun RepositoryHandler.repsy(): MavenArtifactRepository{
return maven(repoProperty("url")){
credentials{
username = repoProperty("username")
password = repoProperty("password")
}
}
}
fun repoProperty(name: String): String = Properties().run {
load(file("repo.properties").inputStream())
get(name) as String
}
repositories {
mavenCentral()
}
publishing{
repositories{
repsy()
}
publications{
create("main", MavenPublication::class.java){
artifactId = project.name
version = project.version as String
groupId = project.group as String
artifact(file(".\\build\\libs\\${project.name}-${project.version}.jar"))
artifact(file(".\\build\\dokka\\html\\index.html")){
classifier = "javadoc"
}
}
}
}
dependencies {
testImplementation(kotlin("test"))
implementation("com.google.code.gson:gson:2.10.1")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(11)
}
字符串
下面是我的仓库的内容:enter image description here
我的藏物被Gradle解决了没问题。然而,Idea无法解析文档。此外,html文件不能正确导航通过,如果下载单独从存储库。Dokka生成的文件包含了很多其他的内容,但是我找到的所有指南都保证我只需要上传index.html文件。
问题是,我做错了什么,以及如何正确地分发dokka生成的kdocs?
1条答案
按热度按时间mwg9r5ms1#
你能试试下面的解决方案吗,让我知道它是怎么回事吗?
字符串
我也提供了
sourcesJar
的代码,因为如果您希望将库发布到Maven Central,这也是必需的。