I am converting a large multi-project setup from an Ant-based build to use Gradle. One of the sub-projects is a library used in some GWT-based applications. This particular library project takes advantage of GWT’s super-source feature. As such I need to exclude a directory that exists inside the source folder from being seen by Eclipse.
However, when I import this into Eclipse, BuildShip ignores the exclude.
I tried appending **/*.java and prepending source/ but that made no difference. I tried setting up a different configuration and sourceSet and using eclipse.classpath.minusConfigurations but got an error about nesting directories.
I managed to fix my own problem. I added the following to my build.gradle:
eclipse {
classpath {
file {
whenMerged {
// Find the "source" entry and add the exclude for the folder containing our super-source code
def src = entries.find { it.path == 'source' }
src.each {
it.excludes = ["com/mycompany/project/gwt/**"]
}
}
}
}
}
This adds the necessary exclusion where I need it. It feels very inelegant though. If anybody knows of a more declarative way to achieve the same end, I would much appreciate it.
@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:
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.