Exclude Kotlin file in Java path

In An Android project, when I need to exclude a Kotlin file:

sourceSets {
    getByName("main") {

        withConvention(KotlinSourceSet::class) {
            kotlin.srcDir("src/main/kotlin")
            kotlin.exclude("**/ExampleExcludeKotlinClass.kt")
        }

    }
}

It works. But when I add this directory into java.srcDirs, it’s full failure.
Is there something I missed?