|
1 | 1 | plugins {
|
2 |
| - id 'org.springframework.boot' version '2.7.1' |
3 |
| - id 'io.spring.dependency-management' version '1.0.11.RELEASE' |
4 |
| - id 'java' |
| 2 | + id 'org.springframework.boot' version '2.7.1' |
| 3 | + id 'io.spring.dependency-management' version '1.0.11.RELEASE' |
| 4 | + id 'org.asciidoctor.jvm.convert' version '3.3.2' |
| 5 | + id 'org.sonarqube' version '3.3' |
| 6 | + id 'java' |
| 7 | + id 'jacoco' |
5 | 8 | }
|
6 | 9 |
|
7 | 10 | group = 'com.allog'
|
8 | 11 | version = '0.0.1-SNAPSHOT'
|
9 | 12 | sourceCompatibility = '11'
|
10 | 13 |
|
| 14 | +ext { |
| 15 | + snippetsDir = file('build/generated-snippets') |
| 16 | +} |
| 17 | + |
| 18 | +configurations { |
| 19 | + asciidoctorExtensions |
| 20 | +} |
| 21 | + |
11 | 22 | repositories {
|
12 |
| - mavenCentral() |
| 23 | + mavenCentral() |
13 | 24 | }
|
14 | 25 |
|
15 | 26 | dependencies {
|
16 |
| - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' |
17 |
| - implementation 'org.springframework.boot:spring-boot-starter-validation' |
18 |
| - implementation 'org.springframework.boot:spring-boot-starter-web' |
19 |
| - runtimeOnly 'com.h2database:h2' |
20 |
| - testImplementation 'org.springframework.boot:spring-boot-starter-test' |
| 27 | + implementation 'org.springframework.boot:spring-boot-starter-jdbc' |
| 28 | + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' |
| 29 | + implementation 'org.springframework.boot:spring-boot-starter-validation' |
| 30 | + implementation 'org.springframework.boot:spring-boot-starter-web' |
| 31 | + |
| 32 | + runtimeOnly 'mysql:mysql-connector-java' |
| 33 | + runtimeOnly 'com.h2database:h2' |
| 34 | + |
| 35 | + testImplementation 'org.springframework.boot:spring-boot-starter-test' |
| 36 | + testImplementation 'io.rest-assured:rest-assured:4.4.0' |
| 37 | + |
| 38 | + // JWT를 위한 의존성 |
| 39 | + implementation 'io.jsonwebtoken:jjwt-api:0.11.5' |
| 40 | + runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' |
| 41 | + runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' |
| 42 | + |
| 43 | + // Restdocs를 위한 의존성 |
| 44 | + asciidoctorExtensions 'org.springframework.restdocs:spring-restdocs-asciidoctor' |
| 45 | + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' |
| 46 | + |
| 47 | + // Sonarqube를 위한 의존성 |
| 48 | + implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3' |
| 49 | +} |
| 50 | + |
| 51 | +test { |
| 52 | + outputs.dir snippetsDir |
| 53 | + useJUnitPlatform() |
| 54 | + finalizedBy 'jacocoTestReport' |
| 55 | +} |
| 56 | + |
| 57 | +jacoco { |
| 58 | + toolVersion = "0.8.8" |
| 59 | +} |
| 60 | + |
| 61 | +jacocoTestReport { |
| 62 | + reports { |
| 63 | + xml.enabled true |
| 64 | + csv.enabled true |
| 65 | + html.enabled true |
| 66 | + |
| 67 | + xml.destination file("${buildDir}/jacoco/index.xml") |
| 68 | + csv.destination file("${buildDir}/jacoco/index.csv") |
| 69 | + html.destination file("${buildDir}/jacoco/index.html") |
| 70 | + } |
| 71 | + |
| 72 | + afterEvaluate { |
| 73 | + classDirectories.setFrom( |
| 74 | + files(classDirectories.files.collect { |
| 75 | + fileTree(dir: it, excludes: [ |
| 76 | + '**/*Application*', |
| 77 | + '**/*Exception*', |
| 78 | + '**/dto/**', |
| 79 | + '**/infrastructure/**', |
| 80 | + '**/global/config/**', |
| 81 | + '**/BaseEntity*', |
| 82 | + '**/ControllerAdvice*', |
| 83 | + '**/AuthorizationExtractor*' |
| 84 | + ]) |
| 85 | + }) |
| 86 | + ) |
| 87 | + } |
| 88 | + |
| 89 | + finalizedBy 'jacocoTestCoverageVerification' |
| 90 | +} |
| 91 | + |
| 92 | +jacocoTestCoverageVerification { |
| 93 | + violationRules { |
| 94 | + rule { |
| 95 | + enabled = true |
| 96 | + element = "CLASS" |
| 97 | + |
| 98 | + // 모든 클래스 각각 라인 커버리지 75% 만족시 빌드 성공 |
| 99 | + limit { |
| 100 | + counter = 'LINE' |
| 101 | + value = 'COVEREDRATIO' |
| 102 | + minimum = 0.75 |
| 103 | + } |
| 104 | + |
| 105 | + excludes = [ |
| 106 | + '*.*Application', |
| 107 | + '*.*Exception', |
| 108 | + '*.dto.*', |
| 109 | + '*.infrastructure.*', |
| 110 | + '*.global.config.*', |
| 111 | + '*.BaseEntity', |
| 112 | + '*.ControllerAdvice', |
| 113 | + '*.AuthorizationExtractor' |
| 114 | + ] |
| 115 | + } |
| 116 | + } |
| 117 | +} |
| 118 | + |
| 119 | +sonarqube { |
| 120 | + properties { |
| 121 | + property 'sonar.projectKey', 'dallog' |
| 122 | + property "sonar.sources", "src" |
| 123 | + property "sonar.language", "java" |
| 124 | + property "sonar.sourceEncoding", "UTF-8" |
| 125 | + property "sonar.profile", "Sonar way" |
| 126 | + property "sonar.java.binaries", "${buildDir}/classes" |
| 127 | + property "sonar.test.inclusions", "**/*Test.java" |
| 128 | + property 'sonar.exclusions', '**/jacoco/**' |
| 129 | + property 'sonar.coverage.exclusions', '**/test/**/*, **/*Application*, **/global/config/**, **/dto/**, **/*Exception*, **/infrastructure/**, **/BaseEntity*, **/ControllerAdvice*, **/AuthorizationExtractor*' |
| 130 | + property "sonar.coverage.jacoco.xmlReportPaths", "${buildDir}/jacoco/index.xml" |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +asciidoctor { |
| 135 | + configurations 'asciidoctorExtensions' |
| 136 | + baseDirFollowsSourceFile() |
| 137 | + inputs.dir snippetsDir |
| 138 | + dependsOn test |
| 139 | +} |
| 140 | + |
| 141 | +asciidoctor.doFirst { |
| 142 | + delete file('src/main/resources/static/docs') |
| 143 | +} |
| 144 | + |
| 145 | +task copyDocument(type: Copy) { |
| 146 | + dependsOn asciidoctor |
| 147 | + |
| 148 | + from "${asciidoctor.outputDir}" |
| 149 | + into file("src/main/resources/static/docs") |
21 | 150 | }
|
22 | 151 |
|
23 |
| -tasks.named('test') { |
24 |
| - useJUnitPlatform() |
| 152 | +bootJar { |
| 153 | + dependsOn copyDocument |
25 | 154 | }
|
0 commit comments