Configuring QueryDSL for Hibernate SQL on gradle

124 views
Skip to first unread message

John Aylward

unread,
Jan 10, 2017, 4:22:14 PM1/10/17
to Querydsl

I opened a ticket https://github.com/querydsl/querydsl/issues/2077 but, I'm now thinking it may not be needed. However, I'm having trouble getting the SQL portion or queryDSL working.


My existing apt config for standard Hibernate in gradle looks like this:

configurations { apt }

sourceSets
{
    main {

        resources {
            exclude '**/.gitignore'
            exclude '**/logback.xml'
            exclude '**/logback-test.xml'
        }
    }
    test
    generated
}


task generateAptSources(type: JavaCompile, group: 'build', description: 'Generates the QueryDSL query types') {
    source = sourceSets.main.java
    classpath = configurations.apt + sourceSets.main.compileClasspath
    options.compilerArgs = [
        '-proc:only',
        '-processor',
        'com.querydsl.apt.hibernate.HibernateAnnotationProcessor',
        // Annotation Processor config options
        '-Aquerydsl.entityAccessors=true'
    ]
    options.warnings = false
    destinationDir = sourceSets.generated.java.srcDirs[0]
    outputs.dir destinationDir
}

compileJava.source generateAptSources.outputs.files

clean {
    delete sourceSets.generated.java.srcDirs
}

dependencies {
   // my normal dependencies excluded.
    apt group: 'com.querydsl', name: 'querydsl-apt', version: querydslVersion
}


I see some instructions here http://www.querydsl.com/static/querydsl/4.1.3/reference/html/ch02.html#d0e431

However, I'm not sure what the Maven is doing. I would like to understand enough of that maven portion to write my own gradle task or add it to my existing apt one.


I do see that there is an Ant task AntMetaDataExporter which looks like it takes similar arguments to the Maven plugin that I should be able to use from gradle. However, I'm not sure what the important pieces of configuration are. Do I need to use Darby, or should I use my actual development database (MySQL in this case)? It also looks like I need to change the namePrefix setting to "S" to match the query samples, but that's not in the example Maven configuration.


Can anyone give me some pointers on how to configure the task?


Thanks.

Reply all
Reply to author
Forward
0 new messages