Kotlin项目的默认buildDir

时间:2019-05-07 20:55:46

标签: kotlin kotlin-dokka

我正在尝试使用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"
    }
}



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

谢谢!

1 个答案:

答案 0 :(得分:1)

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

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

assemble.dependsOn(dokka)