kotlin 项目的默认 buildDir

Default buildDir for kotlin projects

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

在成功 ./gradlew build.

之后,我不太清楚 javadocs 的位置

它说它们应该在 $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"
    }
}



我希望得到一两个正确方向的指示。

谢谢!

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

buildDir 中可能缺少 dokka 输出目录 javadoc,因为 dokka 任务之前从未 运行。您的 build.gradle 文件似乎与 dokka 任务或其输出没有任何依赖关系,因此当您 运行 正在 build 或 [=18] 时它不会被触发=] 任务。您可以尝试 运行 显式地使用它:./gradlew dokka 或将该任务的依赖项添加到其他生命周期任务中,例如

assemble.dependsOn(dokka)