IntelliJ 15 with QueryDSL and Gradle

Do you see your QClasses being generated in the Gradle output? From your error it looks like it's already passed the point where it should generate them.

I think the problem is you are not configuring the JPAAnnotationProcessor. This is done as a convenience in gradle by appending :jpa to your querydsl-apt dependency. In Maven, you apply the plugin manually.

I have the below in my build.gradle related to querydsl.

idea {
    module {
        sourceDirs += file('generated/')
        generatedSourceDirs += file('generated/')
    }
}
[...]
compile "com.querydsl:querydsl-root:$querydslVersion"
compile "com.querydsl:querydsl-jpa:$querydslVersion"
compile "com.querydsl:querydsl-apt:$querydslVersion:jpa

The idea block just auto-configures the generated source dir in IDEA, so that in-IDE builds work correctly.

EDIT:

The JPAAnnotationProcessor output looks like the below.

Note: Running JPAAnnotationProcessor
Note: Serializing Supertypes
Note: Generating com.myclass.example.QMappedSuperClass for [com.myclass.example.MappedSuperClass]
Note: Serializing Entity types
Note: Generating com.myclass.example.QMyClass for [com.myclass.example.MyClass]

EDIT:

I wasn't familiar with the ewerk plugin, so I looked. It appears that it is trying to activate the JPAAnnotationProcessor for you. You may need to set the JPA flag per the documentation here as it defaults to false.

See comment thread regarding dependency issues. EDIT: For Gradle 4.6+, you can use the annotationProcessor syntax.

api "com.querydsl:querydsl-root:$querydslVersion"
api "com.querydsl:querydsl-jpa:$querydslVersion"
annotationProcessor "com.querydsl:querydsl-apt:$querydslVersion:jpa"

If anyone wants to do this with Kotlin and the Gradle kotlin dsl here's how you do it with that setup:

build.gradle.kts

plugins {
    [...]
    id("org.jetbrains.kotlin.kapt") version kotlinVersion
}

dependencies {
    [...]
    compile("com.querydsl:querydsl-core:$queryDslVersion")
    compile("com.querydsl:querydsl-jpa:$queryDslVersion")
    kapt("com.querydsl:querydsl-apt:$queryDslVersion:jpa")
}

Note you may need to use Java 8 for Gradle until a Kapt bug is fixed in Kotlin 1.2.20.