I'm unable to configure gradle to generate the query types for Querydsl. Following advices like #2444, my configuration looks as follows:
plugins {
id 'org.springframework.boot' version '2.3.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-web'
compile 'com.querydsl:querydsl-mongodb:4.3.1'
annotationProcessor 'com.querydsl:querydsl-apt:4.3.1:morphia'
annotationProcessor 'org.springframework.boot:spring-boot-starter-data-mongodb'
}
The query types are not generated.
Gradle version: 6.4.1
Unfortunately, the documentation provides only a configuration for maven and all other guides on the web seem to be deprecated.
Sample repository: https://github.com/viktorgt/spring-mongo-querydsl
Hi @viktorgt please try this, I'm able to generate the Q-Classes with this.. hope it helps you and its also running for me.. Note I'm not using the Morphia annotations and the dependency, instead i'm using @com.querydsl.core.annotations.QueryEntity
and as for your build.gradle
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
dependencies {
//your general spring data and other spring dependencies
compileOnly 'com.querydsl:querydsl-apt'
compile 'com.querydsl:querydsl-mongodb:4.3.1'
compile 'com.querydsl:querydsl-core'
annotationProcessor ('com.querydsl:querydsl-apt:4.3.1:general', 'javax.annotation:javax.annotation-api')
}
//Your path can be as per your choice of source directory for the Q-Classes mine is /src/main/generated/
def queryDslOutput = file(new File(projectDir, '/src/main/generated/'))
sourceSets {
generated {
java {
srcDir queryDslOutput
}
}
}
compileJava {
options.compilerArgs << '-s'
options.compilerArgs << "$projectDir/src/main/generated/"
doFirst {
file(new File(projectDir, '/src/main/generated/')).mkdirs();
}
}
Edit: I'm also not using the JPA Annotations or the Spring-Data-JPA
Gradle Version: 6.5
P.S: I've edited this comment a lot of times, because I'm new to Github.
@somudas93 thank you. This one actually works 馃憤
We could also add delete(files("${projectDir}/src/main/generated/"))
in the doFirst
part of the compileJava
, so old files will be overridden, when there are changes.