Gradle 4.10.x으로 변경후 Lombok이 동작을 하지 않고, queryDSL도 클래스 파일 생성이 되지 않아 여러모로 찾아보고 간략히 정리해 봤습니다.

[Gradle 설정 내용]

[Dependencies]

dependencies {
def querydslVersion = "4.2.1"
compile ("com.querydsl:querydsl-core:$querydslVersion")
compile ("com.querydsl:querydsl-apt:$querydslVersion")
compile ("com.querydsl:querydsl-jpa:$querydslVersion")
compile group: 'org.codehaus.groovy', name: 'groovy-all', version:'2.5.2'
compile (group: 'com.zaxxer', name: 'HikariCP', version: '3.2.0'){
force = true
}
...
...
}

[query-dsl configuration]

def queryDslOutput = file("src-gen/main/java")

task generateQueryDSL(type: JavaCompile, group: 'build') {
doFirst {
if (!queryDslOutput.exists()) {
logger.info("Creating `$queryDslOutput` directory")

if (!queryDslOutput.mkdirs()) {
throw new InvalidUserDataException("Unable to create `$queryDslOutput` directory")
}
}
}

source = sourceSets.main.java
classpath = configurations.compile + configurations.compileOnly
options.compilerArgs = [
"-proc:only",

/** Warning - Insert Two lines all below **/
"-processor", "com.querydsl.apt.jpa.JPAAnnotationProcessor",
"-processor", 'com.querydsl.apt.jpa.JPAAnnotationProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor'
/** Warning **/
]
destinationDir = queryDslOutput
}

//compileTestJava.dependsOn(generateQueryDSL)
compileJava.dependsOn(generateQueryDSL)


clean {
delete queryDslOutput
}

sourceSets {
main {
java {
srcDir "src-gen/main/java"
}
}
}

[Lombok Configuration]

plugins {
id 'io.franzbecker.gradle-lombok' version '1.14'
...
...
}
...
...

lombok { // optional: values below are the defaults
version = '1.18.4'
sha256 = ""
}
 

Leave a Reply

Your email address will not be published. Required fields are marked *