How can I declare an exclusion on my source folder?

@donat Thank you so much for taking the time to setup the test project and look at this. Using your test project as a starting point I was able to pinpoint the source of my problem.

In the full scale build.gradle file, I was also declaring a resources section in the sourceSets. The resources overlap the java, i.e. they are in the same directory structure mixed in with the .java source files (this is due to history - if we started again we would probably separate this out). I was not declaring the exclusion in the resources section. So I had:

sourceSets {
    main {
        java {
            srcDirs = ['source', 'source-gen']
            exclude 'com/franke/awe/cubicle/gwt/**'
        }
        resources {
            srcDirs = ['source', 'source-gen']
        }
    }
}

But what I really need is:

sourceSets {
    main {
        java {
            srcDirs = ['source', 'source-gen']
            exclude 'com/franke/awe/cubicle/gwt/**'
        }
        resources {
            srcDirs = ['source', 'source-gen']
            exclude 'com/franke/awe/cubicle/gwt/**'
        }
    }
}

With this in place it works as expected. Sorry I did not include this information in my initial post. At the time I assumed that the resources section would be treated separately. Thinking back on it now, I can see why it also makes sense that it is not.

Thanks again for your help!

1 Like