0

我正在尝试使用 dokka https://kotlinlang.org/docs/reference/kotlin-doc.html将文档添加到我的项目中

成功后我不太能弄清楚它们的javadocs位置./gradlew build.

它说他们应该在那里,$buildDir/javadoc但我不确定buidlDir指向哪里。

我的 build.gradle 文件是这样的:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'

    }

}
plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.11'
     id 'org.jetbrains.dokka' version '0.9.18'

    // id("org.jmailen.kotlinter") version "1.23.1"

}

dokka {
    outputFormat = 'html'
    outputDirectory = "$buildDir/javadoc"
}


group 'com.github.me.dynamik'
version '1.0-SNAPSHOT'
apply plugin: 'application'
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'com.github.johnrengelman.shadow'




mainClassName = 'com.github.me.dynamik.interpreter.MainEntryKt'

repositories {
    mavenCentral()
    jcenter()
    maven { setUrl("https://dl.bintray.com/hotkeytlt/maven") }
    maven {
        url = uri("https://plugins.gradle.org/m2/")
    }

}
configurations {
    ktlint
}
dependencies {

    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    compile 'com.github.h0tk3y.betterParse:better-parse-jvm:0.4.0-alpha-3'
    // https://mvnrepository.com/artifact/junit/junit
    testCompile group: 'junit', name: 'junit', version: '4.4'
    implementation 'com.github.ajalt:clikt:1.7.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.0'


}



compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

run {
    standardInput = System.in
}

jar {
    manifest {
        attributes 'Main-Class': 'com.github.me.dynamik.interpreter.MainEntryKt'
    }
}

test {

    // Always run tests, even when nothing changed.
    dependsOn 'cleanTest'

    // Show test results.
    testLogging {
        events "passed", "skipped", "failed"
    }
}



我希望在正确的方向上有一两个指针。

谢谢!

4

1 回答 1

1

在 Gradle 中,项目属性buildDir默认指向build项目目录的子目录。

dokka 输出目录javadoc可能会丢失,buildDir因为该dokka任务以前从未运行过。dokka您的 build.gradle 文件似乎对任务或其输出没有任何依赖关系,因此在您运行buildassemble执行任务时不会触发它。您可以尝试显式运行它:./gradlew dokka或将该任务的依赖项添加到其他生命周期任务,例如

assemble.dependsOn(dokka)
于 2019-05-08T15:09:02.850 回答