Search code examples
kotlinkotlin-dokka

Default buildDir for kotlin projects


I'm trying to add documentation to my project with dokka https://kotlinlang.org/docs/reference/kotlin-doc.html

I'm not quite able to figure out where the javadocs are located after doing a successful ./gradlew build.

It says there they should be in $buildDir/javadoc but I'm not sure where buidlDir is pointing to.

My build.gradle file is this:

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"
    }
}



I'd love a pointer or two in the right direction.

Thank you!


Solution

  • In Gradle the project property buildDir points by default to the subdirectory build of your project directory.

    The dokka output directory javadoc may be missing in buildDir because the dokka task has never run before. Your build.gradle file seems not to have any dependencies on the dokka task or its output, so it isn't triggered when you're running build or assemble tasks. You can try running it explicitly: ./gradlew dokka or add a dependency on that task to some other lifecycle task, e.g

    assemble.dependsOn(dokka)