Custom GroovyCompilation task fails to find the java sources

Hi there,
In a project I’m working on I’ve been using both Java and Groovy. The compilation is done by only the Groovy compiler, and it seems to work fine. Now I’m trying to incorporate the QueryDSL library into the project, but the setup I have exhibits a very strange behaviour, which I’ll explain below.

These are the relevant parts of the gradle file: = [] // don't compile Java code twice
    sourceSets.main.groovy.srcDirs += ['src/main/java'] = [] // don't compile Java code twice
    sourceSets.test.groovy.srcDirs += ['src/test/java'] = ['src/main/java/generated']

And this is the task that is supposed to generate the QueryDSL classes:

task generateQueryDSL(type: GroovyCompile, group: 'build', description: 'Generates the QueryDSL query types') {
        source = sourceSets.main.groovy
        classpath = configurations.compile + configurations.querydslapt
        options.compilerArgs = [
                "-processor", ""
//                "-processor", "com.mysema.query.apt.QuerydslAnnotationProcessor"
        destinationDir =

And here is the weird part - in this setup, the generation of classes works in gradle 2.4, but not in a newer version - the exceptions below are printed. If I change the processor to the commented one (QuerydslAnnotationProcessor) I the same exceptions are returned no matter the gradle version.

/path/to/project/common/src/main/groovy/com/company/project/model/common/Person.groovy: 3: unable to resolve class
 @ line 3, column 1.

/path/to/project/common/src/main/groovy/com/company/project/model/common/Person.groovy: 5: unable to resolve class
 @ line 5, column 1.

And a lot more of these errors are printed, and all of them are about Java classes which are referenced from Groovy ones.

I’m wrestling with a similar problem regarding QueryDSL + Spring Boot, did you make progress on this? I would recommend moving your generated source directory out from your java directory like this = ['src/main/generated']

Having generated sources under the java directory seems incorrect and probably throws gradle for a loop.