plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.0'
    id 'io.spring.dependency-management' version '1.1.0'
    id 'jacoco'
}

test{
    finalizedBy 'jacocoTestReport'
}

group = 'flab'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.1.0'
    implementation 'org.springframework.boot:spring-boot-starter-validation'

    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
    implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
    implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'

    implementation 'org.springframework.boot:spring-boot-starter-data-redis'
    implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.1'
    implementation 'com.mysql:mysql-connector-j'

    implementation group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.238'
    implementation 'javax.xml.bind:jaxb-api:2.3.0'
    implementation 'org.springframework.boot:spring-boot-starter-security'

    implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '3.1.0'
    implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'

    implementation 'org.springframework.boot:spring-boot-starter-amqp'

    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'io.micrometer:micrometer-registry-prometheus'

    compileOnly'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'

    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'

    testImplementation("org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.2")
    testImplementation 'org.springframework.boot:spring-boot-starter-jdbc' // test용 h2 database사용을 위함.
    testImplementation 'org.projectlombok:lombok:1.18.22'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.rest-assured:rest-assured'
    runtimeOnly 'com.h2database:h2'

    testCompileOnly(group: 'it.ozimov', name: 'embedded-redis', version: '0.7.2')
    testImplementation 'org.springframework.security:spring-security-test'
}

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

tasks.named('processResources') {
    dependsOn(copyPrivate)
}

jacocoTestReport {
    reports {
        html.enabled true
        html.destination file("${buildDir}/jacoco/index.html")
    }
}

jacoco {
    toolVersion = "0.8.8"
}

jacocoTestCoverageVerification {
    violationRules {
        rule {
            element = 'CLASS'

            limit {
                counter = 'BRANCH'
                value = 'COVEREDRATIO'
                minimum = 0.10
            }
        }
    }
}

task copyPrivate(type: Copy) {
    from './submodules/Prostargram_submodule-data'
    include "*.yml"
    into 'src/main/resources'
}

build.dependsOn(copyPrivate)
