Justin의 개발 로그
article thumbnail

 

새 프로젝트 설정

  • IntelliJ -> File -> New Project
  • Gradle, Java, Web 체크 후 [Next]

  • Name 설정 -> [Finish]

 

 brew install gradle

 

build.gradle 수정

//[AS-IS]
plugins {
    id 'java'
    id 'war'
}

group 'org.example'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}
... 생략


//[TO-BE]
plugins {
    id 'org.springframework.boot' version '2.2.2.RELEASE'
    id 'io.spring.dependency-management' version '1.0.8.RELEASE'
    id 'java'
    id 'war'
    id 'jacoco'
}

group 'org.example'
version '1.0-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_1_8

jacoco {
    toolVersion = '0.8.7'
}

//War 패키징 Task 미실행
bootWar.enabled = false

repositories {
    mavenCentral()
}

dependencies {
    implementation ('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.junit.jupiter:junit-jupiter-api')
    testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine')
    testImplementation ('org.springframework.boot:spring-boot-starter-test')

}

test {
     useJUnitPlatform()
    // finalizedBy jacocoTestReport
}


jacocoTestReport {
    dependsOn test

    reports {
        html.enabled true
        xml.enabled true
        csv.enabled true

        html.destination file("$buildDir/jacoco/jacoco.html")
        xml.destination file("$buildDir/jacoco/jacoco.xml")
    }


//    def Qdomains = []
//    for (qPattern in '**/QA'..'**/QZ') {
//        Qdomains.add(qPattern + '*')
//    }
//
//    afterEvaluate {
//        classDirectories.setFrom(
//                files(classDirectories.files.collect {
//                    fileTree(dir: it, excludes: [
//                            '**/BlogApplication*',
//                            '**/*Request*',
//                            '**/*Response*',
//                            '**/*Dto*',
//                    ] + Qdomains)
//                })
//        )
//    }

    finalizedBy 'jacocoTestCoverageVerification'
}

jacocoTestCoverageVerification {
    def Qdomains = []
    for (qPattern in '*.QA'..'*.QZ') {
        Qdomains.add(qPattern + '*')
    }

    violationRules {
        rule {
            element = 'CLASS'
            enabled = true

            limit {
                counter = 'LINE'
                value = 'COVEREDRATIO'
                minimum = 0.90
            }

            limit {
                counter = 'METHOD'
                value = 'COVEREDRATIO'
                minimum = 0.90
            }

            /*
            excludes = [
                    '**.*BlogApplication*',
                    '**.*Request*',
                    '**.*Response*',
                    '**.*Dto*',
            ] + Qdomains
            */
        }
    }
}
profile

Justin의 개발 로그

@라이프노트

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!