plugins {
    id 'java'
    id 'org.springframework.boot' version '2.6.7'
    id 'io.spring.dependency-management' version '1.0.14.RELEASE'
    id 'groovy'
}

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

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

bootJar {
    archiveFileName = "app.jar"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.retry:spring-retry'

    // redis
    implementation 'org.springframework.boot:spring-boot-starter-data-redis'

    implementation 'io.seruco.encoding:base62:0.1.3'

    // handlebars
    implementation 'pl.allegro.tech.boot:handlebars-spring-boot-starter:0.3.4'

    compileOnly 'org.projectlombok:lombok'
    runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'

    // spock
    testImplementation 'org.spockframework:spock-core:2.3-groovy-3.0'
    testImplementation 'org.spockframework:spock-spring:2.3-groovy-3.0'

    // 런타임에 클래스 기반 spock mock 을 만들기 위해서 필요
    testImplementation 'net.bytebuddy:byte-buddy:1.12.19'

    // testcontainers
    testImplementation 'org.testcontainers:spock:1.17.6'
    testImplementation 'org.testcontainers:mariadb:1.17.6'

    // mockWebServer
    testImplementation 'com.squareup.okhttp3:okhttp:4.10.0'
    testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
}

tasks.named('test') {
    useJUnitPlatform()
}

processTestResources {
    boolean hasProperty = project.hasProperty("KAKAO_REST_API_KEY")
    System.out.println("Set kakao rest api key: $hasProperty")
    filesMatching("**/application.yml") {
        expand(project.properties)
    }
}
