Can not access Q Classes generated by querydsl in spring boot and gradle application

1,621 views
Skip to first unread message

Ashish Meshram

unread,
Jul 30, 2016, 7:09:10 AM7/30/16
to Querydsl
I am trying to use querydsl in my spring boot application. It also uses spring data jpa and gradle.

This is how query dsl is configured. 

    sourceSets {
        generated {
            java {
                srcDirs = ['src/main/generated']
            }
        }
    }
    
    configurations {
        querydslapt
    }
    
    dependencies {
        compile group: 'com.mysema.querydsl', name: 'querydsl-jpa', version: querydsl_version
        querydslapt group: 'com.mysema.querydsl', name: 'querydsl-apt', version: querydsl_version
    }
    
    task generateQueryDSL(type: JavaCompile, group: 'build', description: 'Generates the QueryDSL query types') {
        source = sourceSets.main.java
        classpath = configurations.compile + configurations.querydslapt
        options.compilerArgs = [
                "-proc:only",
                "-processor", "com.mysema.query.apt.jpa.JPAAnnotationProcessor"
        ]
        destinationDir = sourceSets.generated.java.srcDirs.iterator().next()
    }
    
    compileJava {
        dependsOn generateQueryDSL
        source generateQueryDSL.destinationDir
    }
    
    compileGeneratedJava {
        dependsOn generateQueryDSL
        options.warnings = false
        classpath += sourceSets.main.runtimeClasspath
    }
    
    clean {
        delete sourceSets.generated.java.srcDirs
    }
    
    idea {
        module {
            sourceDirs += file('src/main/generated')
        }
    }

When I build the project Q Classes gets generated. But when I try to use those classes in my service classes. It gives can not resolve symbol at compile time. I just cant import those Q classes.  


Disclaimer: The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information.  If you are not the intended recipient or have received this email in error you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

timowest

unread,
Aug 5, 2016, 7:32:17 AM8/5/16
to Querydsl
Hi.

We don't provide official support for Gradle, so someone else might be able to help here.

Timo
Reply all
Reply to author
Forward
0 new messages