Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REFACTOR] Querydsl을 이용한 쿼리 최적화 #112

Merged
merged 9 commits into from
Oct 24, 2023
Prev Previous commit
Next Next commit
[FIX] Querydsl 빌드 오류 해결 #108
  • Loading branch information
jun02160 committed Oct 11, 2023
commit 44ebfa16a195532f048ef81da7ced1f6e9673d69
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ build/
!**/src/main/**/build/
!**/src/test/**/build/

## Querydsl
umbba-domain/src/main/generated

### STS ###
.apt_generated
.classpath
Expand Down
78 changes: 46 additions & 32 deletions umbba-domain/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
/*buildscript {
ext {
queryDslVersion = "5.0.0"
}
}
plugins {
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}
}*/
bootJar { enabled = false }
jar { enabled = true }

Expand All @@ -28,44 +28,58 @@ dependencies {
implementation group: "io.jsonwebtoken", name: "jjwt-jackson", version: "0.11.2"

// querydsl
implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
compile("com.querydsl:querydsl-core")
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties["querydsl.version"]}:jpa"
annotationProcessor "jakarta.persistence:jakarta.persistence-api:2.2.3"
annotationProcessor "jakarta.annotation:jakarta.annotation-api:1.3.5"
}

//def queryDslDir = "build/querydsl/generated"
//
//sourceSets {
// main.java.srcDirs += [queryDslDir]
//}
//
//tasks.withType(JavaCompile) {
// options.annotationProcessorGeneratedSourcesDirectory = file(queryDslDir)
//}
//
//clean.doLast {
// file(queryDslDir).deleteDir()
//}
// implementation "com.querydsl:querydsl-jpa:${queryDslVersion}"
// implementation "com.querydsl:querydsl-apt:${queryDslVersion}"
// compile("com.querydsl:querydsl-core")
// annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties["querydsl.version"]}:jpa"
// annotationProcessor "jakarta.persistence:jakarta.persistence-api:2.2.3"
// annotationProcessor "jakarta.annotation:jakarta.annotation-api:1.3.5"

def querydslDir = "$buildDir/generated/querydsl" // Q클래스 생성 위치
// querydsl
// queryDSL 설정
implementation "com.querydsl:querydsl-jpa"
implementation "com.querydsl:querydsl-core"
implementation "com.querydsl:querydsl-collections"
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa" // querydsl JPAAnnotationProcessor 사용 지정
annotationProcessor "jakarta.annotation:jakarta.annotation-api" // java.lang.NoClassDefFoundError (javax.annotation.Generated) 대응 코드
annotationProcessor "jakarta.persistence:jakarta.persistence-api" // java.lang.NoClassDefFoundError (javax.annotation.Entity) 대응 코드

querydsl {
jpa = true
querydslSourcesDir = querydslDir
}

def queryDslDir = "build/querydsl/generated"

sourceSets {
main.java.srcDir querydslDir
main.java.srcDirs += [queryDslDir]
}

configurations {
querydsl.extendsFrom compileClasspath
tasks.withType(JavaCompile) {
options.getGeneratedSourceOutputDirectory().set(file(queryDslDir))
}

compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
clean.doLast {
file(queryDslDir).deleteDir()
}

//def querydslDir = "$buildDir/generated/querydsl" // Q클래스 생성 위치
//
//clean {
// delete file(querydslDir)
//}
//
//querydsl {
// jpa = true
// querydslSourcesDir = querydslDir
//}
//
//sourceSets {
// main.java.srcDir querydslDir
//}
//
//configurations {
// querydsl.extendsFrom compileClasspath
//}
//
//compileQuerydsl {
// options.annotationProcessorPath = configurations.querydsl
//}