Hi all, I hope you are well. I have a question rel...
# dokka
c
Hi all, I hope you are well. I have a question related to Dokka. Is there a way to build
only .kt files
? I'm trying to do this because we are currently trying to migrate to Kotlin from Java (android) and found that Javadoc HTML created by Dokka does not have 1.
@since
information (reported at Github) 2. and failed to find a way to insert headers, footers, etc. to Dokka configs (like mentioned here). Hence if we built all our sources (
java
+
kt
) using Dokka we will be losing some information we currently have. So instead we are considering building only
.kt
files using Dokka to minimize loss of information and wait for feature updates for the above. Is there a way to build only
.kt
files or exclude
.java
files from being built by Dokka? Thank you.
l
If you happen to have them in different packages, yes. Otherwise I can not think of any viable way here. 🤔
Maybe you can add your java files to
suppressedFiles
? Haven’t tested or found any documentation though. Edit: sample usage
m
There is no way to do it out of the box, but some workarounds should be possible depending on your project structure. How do you keep your java and kotlin files? Do they have a separate packages? Or maybe sourcesets?
c
Thanks for answering @Lukas K-G and @Marcin Aman. They are in the same source sets, same packages, and same directory. What I first tried was using
'org.jetbrains.dokka-android'
, but it seemed like this plugin do not support
suppressedFiles
command (groovy Gradle does not compile) and I tried switching to standard plugin
"org.jetbrains.dokka"
. But then
gradlew dokkaJavadoc
produced an error. Below is the error message.
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
kotlin.jvm.internal.Reflection.typeOf(Ljava/lang/Class;)Lkotlin/reflect/KType;
Maybe an Android project is not suitable for latest dokka and dokka android plugin is not up-to-date with dokka. (the latest android dokka plugin update was March 2019. https://plugins.gradle.org/plugin/org.jetbrains.dokka-android)
m
well it looks like an incorrect groovy configuration Could you paste your configuration from the newer version? Dokka-android is quite old and is not supported in newer versions of dokka? Default dokka should work out of the box
c
Thank you so much for helping me out. top-level build.gradle
Copy code
buildscript {
    ext.kotlin_version = '1.4.31'
    ext.dokka_version = "1.4.30"
    repositories {
...
app-level build.gradle
Copy code
apply plugin: "org.jetbrains.dokka"
...
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
        classpath("org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}")
    }
}
...
tasks.named("dokkaHtml") {
    outputDirectory.set(file("../doc"))
}
then when I run
./gradlew dokkaHtml
then below error message is printed:
Copy code
FAILURE: Build failed with an exception.

* What went wrong:
kotlin.jvm.internal.Reflection.typeOf(Ljava/lang/Class;)Lkotlin/reflect/KType;
this is what is printed when I run
./gradlew dokkaHtml --stacktrace
I'm using gradle version
5.4.1
. Again, thank you so much for trying to help me out. 🙇‍♂️
m
I think that this is a gradle <-> kotlin compatibility issue. We use
typeOf
function that is present in kotlin since 1.3 and i think that gradles lower than
5.6
doesn’t have it. Its hard for me to confirm it for sure since i haven’t found any compatibility matrixes but upgrading to 5.6 makes dokka task pass.
🙇‍♂️ 1