# Exclude does not work at sourceSets

**URL:** <https://discuss.gradle.org/t/exclude-does-not-work-at-sourcesets/43149>\
**Category:** Help/Discuss\
**Created:** [June 16, 2022, 9:49am UTC](https://discuss.gradle.org/t/exclude-does-not-work-at-sourcesets/43149 "2022-06-16T09:49:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neo](https://avatars.discourse-cdn.com/v4/letter/n/9fc348/32.png) [@Neo](https://discuss.gradle.org/u/Neo)\
**Post date:** [June 16, 2022, 9:49am UTC](https://discuss.gradle.org/t/exclude-does-not-work-at-sourcesets/43149/1 "2022-06-16T09:49:44Z")

</div>

I am Android Devloper

i know sourceSets can use include & exclude

like Chromium build.gradle use include at sourceSets to join java file

and some example say can use exclude to

like : [How can I exclude certain java files from being compiled?](https://discuss.gradle.org/t/how-can-i-exclude-certain-java-files-from-being-compiled/5287)

but some answer say "exclude not work "

> <https://stackoverflow.com/questions/39417891/gradle-exclude-file-from-sourceset-not-working>

i know the full producetflavor must move class of flavor into flavor`s folder  
and del the same name at main folder

but now l am lazy

i want use

sourceSets srcDirs += [’./src/flavor1/java’] and use exclude

exclude “.\main\java\xx\xxx\app\xxxApplication.kt”

but it not work

can help me ?

PS. why use exclude not move ? because i can use dir give file list let main git not change

THX

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [June 16, 2022, 5:12pm UTC](https://discuss.gradle.org/t/exclude-does-not-work-at-sourcesets/43149/2 "2022-06-16T17:12:02Z")

</div>

Your exclude is most probably simply not correct, it also looks quite fishy to me.  
Especially as is starts with `.` and contains unescaped backslashes.  
But from your description it is also - at least to me - unclear what exactly you tried.  
Maybe you should provide an [MCVE](https://stackoverflow.com/help/mcve) to make clear what you tried and how to fix it.
