본문 바로가기
개발자의 삶/Gradle

[Gradle] QueryDSL 설정

by 나.R.D.(Rule Destoryer) 2020. 3. 10.

plugins {
id 'org.springframework.boot' version '2.2.5.RELEASE'
id 'java'
}

apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

// QueryDSL Version
def queryDSLVersion = '4.2.2'
// QueryDSL PATH
def generated = "src/main/generated"

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'

implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.6.1'

compileOnly 'org.projectlombok:lombok'
// QueryDSL - DSL(Domain Specific Language)
compile("com.querydsl:querydsl-core:${queryDSLVersion}")
compile("com.querydsl:querydsl-jpa:${queryDSLVersion}")
compile("com.querydsl:querydsl-apt:${queryDSLVersion}")
annotationProcessor(
"com.querydsl:querydsl-apt:${queryDSLVersion}:jpa",
"org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final",
"javax.annotation:javax.annotation-api",
"org.projectlombok:lombok"
)
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}

sourceSets {
main.java.srcDirs += [ generated ]
}

tasks.withType(JavaCompile) {
options.annotationProcessorGeneratedSourcesDirectory = file(generated)
}

clean.doLast {
file(generated).deleteDir()
}

test {
useJUnitPlatform()
}

관련 링크

[SpringBoot] Gradle 을 이용해서 JPA(+QueryDSL) 프로젝트 설정

프로젝트를 구성할 수 있는 방법이 너무 많아서 구성하는데 너무 짜증났다 ㅋ 뭘로 설정해야 가장 좋을까 하다가 기본 start.spring.io 에서 생성한 프로젝트를 기준으로 plugin 을 추가해주는 방법을

seodaeya.tistory.com

반응형

댓글