Element 'dokka' of type 'org.jetbrains.dokka.gradle.DokkaTask_Decorated' from container 'task set' cannot be cast to 'org.jetbrains.dokka.gradle.DokkaTask'

Hello,
Maybe you can help me since folks at Dokka don’t give a damn about github issues :disappointed:

I was following your tutorial and I’m having troubles with dokka task. I’ve a build.gradle.kts file responsible for publishing my library which is applied to the library build.gradle:

build.gradle

apply plugin: 'com.android.library'
apply from: rootProject.file('deploy-bintray.gradle.kts')

deploy-bintray.gradle.kts

import com.jfrog.bintray.gradle.BintrayExtension
import com.jfrog.bintray.gradle.BintrayPlugin
import org.jetbrains.dokka.gradle.DokkaTask
import java.io.FileInputStream
import java.util.*

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5")
        classpath("org.jetbrains.dokka:dokka-gradle-plugin:0.10.1")
    }
}

apply(plugin = "maven-publish")
apply(plugin = "org.jetbrains.dokka")
plugins.apply(BintrayPlugin::class.java) //https://github.com/bintray/gradle-bintray-plugin/issues/301

val bintrayRepo = properties["bintrayRepo"].toString()
val bintrayName = properties["bintrayName"].toString()
val libraryVersion = properties["libraryVersion"].toString()
val libraryDescription = properties["libraryDescription"].toString()
val siteUrl = properties["siteUrl"].toString()
val gitUrl = properties["gitUrl"].toString()

configure<BintrayExtension> {
    if (project.rootProject.file("local.properties").exists()) {
        val fis = FileInputStream(project.rootProject.file("local.properties"))
        val prop = Properties()
        prop.load(fis)
        user = prop.getProperty("bintray.user", "")
        key = prop.getProperty("bintray.apiKey", "")
    } else {
        user = System.getenv("bintrayUser")
        key = System.getenv("bintrayApiKey")
    }

    setPublications(bintrayRepo)

    pkg.apply {
        repo = bintrayRepo
        name = bintrayName
        description = libraryDescription
        websiteUrl = siteUrl
        issueTrackerUrl = "$siteUrl/issues"
        vcsUrl = gitUrl
        setLicenses("Apache-2.0")
        publish = true
        publicDownloadNumbers = true
        version.apply {
            name = libraryVersion
            vcsTag = libraryVersion
            desc = libraryDescription
            released = Date().toString()
        }
    }
}

configure<PublishingExtension> {
    val artifact = properties["artifact"].toString()
    val publishedGroupId = properties["publishedGroupId"].toString()
    val libraryName = properties["libraryName"].toString()
    val developerId = properties["developerId"].toString()
    val developerName = properties["developerName"].toString()
    val developerEmail = properties["developerEmail"].toString()

    val sourcesJar by tasks.registering(Jar::class) {
        archiveClassifier.set("sources")
        from(project.the<SourceSetContainer>()["main"].allSource)
    }

    val dokkaJar by tasks.creating(Jar::class) {
        val dokka by tasks.getting(DokkaTask::class) {
            outputFormat = "html"
            outputDirectory = "$buildDir/javadoc"
        }
        group = JavaBasePlugin.DOCUMENTATION_GROUP
        description = "Assembles Kotlin docs with Dokka"
        archiveClassifier.set("javadoc")
        from(dokka)
    }

    publications {
        create<MavenPublication>(bintrayRepo) {
            groupId = publishedGroupId
            artifactId = artifact
            version = libraryVersion

            from(components["java"])
            artifact(sourcesJar.get())
            artifact(dokkaJar)

            pom {
                packaging = "aar"
                name.set(libraryName)
                description.set(libraryDescription)
                url.set(siteUrl)
                scm {
                    connection.set(gitUrl)
                    developerConnection.set(connection.get())
                    url.set(siteUrl)
                }
                issueManagement { url.set("$siteUrl/issues") }
                licenses {
                    license {
                        name.set("The Apache Software License, Version 2.0")
                        url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
                    }
                }
                developers {
                    developer {
                        id.set(developerId)
                        name.set(developerName)
                        email.set(developerEmail)
                    }
                }
            }
        }
    }
}

I’ve tried replacing dokka with javadocs but I can’t translate this:

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

into .kts files because it latter fails saying I cant add java plugin into a android-library, etc…

Well, am interested in making Dokka work.
Thanks for your time.