# Exclude Kotlin file in Java path

**URL:** <https://discuss.kotlinlang.org/t/exclude-kotlin-file-in-java-path/17053>\
**Category:** Android\
**Created:** [April 10, 2020, 2:23am UTC](https://discuss.kotlinlang.org/t/exclude-kotlin-file-in-java-path/17053 "2020-04-10T02:23:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crease.xu](https://avatars.discourse-cdn.com/v4/letter/c/3ab097/32.png) [@crease.xu](https://discuss.kotlinlang.org/u/crease.xu)\
**Post date:** [April 10, 2020, 2:23am UTC](https://discuss.kotlinlang.org/t/exclude-kotlin-file-in-java-path/17053/1 "2020-04-10T02:23:23Z")

</div>

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？
