# Exclude Kotlin files from gradle build

**URL:** <https://discuss.gradle.org/t/exclude-kotlin-files-from-gradle-build/31237>\
**Category:** Help/Discuss\
**Tags:** android\
**Created:** [April 2, 2019, 10:20am UTC](https://discuss.gradle.org/t/exclude-kotlin-files-from-gradle-build/31237 "2019-04-02T10:20:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![int3rstell4r](https://avatars.discourse-cdn.com/v4/letter/i/4af34b/32.png) [@int3rstell4r](https://discuss.gradle.org/u/int3rstell4r)\
**Post date:** [April 2, 2019, 10:20am UTC](https://discuss.gradle.org/t/exclude-kotlin-files-from-gradle-build/31237/1 "2019-04-02T10:20:51Z")

</div>

Hi!

I want to exclude Kotlin files from a gradle build. As long as the files are .java files everthing works fine but after converting them to Kotlin the files seem not to be ignored anymore. Every excluded java file throws a ClassNotFoundException while the excluded Kotlin files behave like “not excluded”.

I added the following to my build.gradle file

```gradle
sourceSets {
    main {
        java {
            exclude '**/excludedFiles'
        }
    }
}

```

I already checked the following links:  
[First](https://discuss.kotlinlang.org/t/how-to-exclude-kotlin-files-from-compiling-with-gradle/11330)  
[Second](https://stackoverflow.com/questions/55470905/exclude-kotlin-files-from-gradle-build-in-android-studio)
