Skip to content

Instantly share code, notes, and snippets.

@edwardbeckett
Created April 13, 2013 06:59
Show Gist options
  • Save edwardbeckett/5377401 to your computer and use it in GitHub Desktop.
Save edwardbeckett/5377401 to your computer and use it in GitHub Desktop.
mysema.querydsl gradle
sourceSets {
generated {
java {
srcDirs = ['src/main/generated']
}
}
}
configurations {
querydslapt
}
dependencies {
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
compile "com.mysema.querydsl:querydsl-jpa:$querydslVersion"
querydslapt "com.mysema.querydsl:querydsl-apt:$querydslVersion"
}
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')
}
}
@milehighcelt
Copy link

I am trying to use querydsl with my spring-boot project. However, I cannot find a working example of using gradle with querydsl. Looking at this gist, I thought it would work. However, the line " querydslapt" is causing Gradle to fail:
Could not find method querydslapt() for arguments [com.mysema.querydsl:querydsl-apt:3.3.2]
I tried changing back to an earlier version, but that failed also:
Could not find method querydslapt() for arguments [com.mysema.querydsl:querydsl-apt:2.8.1]

The line that fails is this:
querydslapt "com.mysema.querydsl:querydsl-apt:2.8.1"

Can you tell me if this script does in fact work, and if so what does querydslapt() do?

@mxab
Copy link

mxab commented Jul 6, 2014

@milehighcelt

are you sure have

configurations {
    querydslapt
}

@TheKojuEffect
Copy link

How can I configure this for groovy based project?

I tried changing as following but MetaModels are not being generated for Entity class but empty directory structure is created.

task generateQueryDSL(type: GroovyCompile, group: 'build', description: 'Generates the QueryDSL query types') {
    source = sourceSets.main.groovy
    classpath = configurations.compile + configurations.querydslapt
    options.compilerArgs = [
            "-proc:only",
            "-processor", "com.mysema.query.apt.jpa.JPAAnnotationProcessor"
    ]
    destinationDir = sourceSets.generated.java.srcDirs.iterator().next()
}```

@pmdusso
Copy link

pmdusso commented Feb 13, 2015

It would be too different to configure the task generateQueryDSL for MongoDB?

@otwm
Copy link

otwm commented Jan 1, 2016

thx a lot!! very useful infomation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment