-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
executable file
·234 lines (200 loc) · 8.02 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
import com.palantir.gradle.docker.DockerExtension
import fr.brouillard.oss.gradle.plugins.JGitverPluginExtensionBranchPolicy
import fr.brouillard.oss.jgitver.Strategies
import io.gitlab.arturbosch.detekt.Detekt
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar
val kotlinVersion: String by project
val springBootVersion: String by project
val springCloudVersion: String by project
val springSecurityOauth2Version: String by project
val springSecurityCoreVersion: String by project
val springDocOpenApiVersion: String by project
val jacocoToolVersion: String by project
val openapiGeneratorVersion: String by project
val postgresVersion: String by project
val flywayVersion: String by project
val hibernateTypesVersion: String by project
val logstashLogbackEncoderVersion: String by project
val slf4jKotlinExtensionVersion: String by project
val testContainers: String by project
val junitPlatformLauncherVersion: String by project
val mockkVersion: String by project
val springMockkVersion: String by project
val striktVersion: String by project
plugins {
kotlin("jvm") apply false
kotlin("plugin.spring") apply false
kotlin("plugin.jpa") apply false
id("org.springframework.boot") apply false
id("io.spring.dependency-management") apply false
id("io.gitlab.arturbosch.detekt") apply false
id("org.jlleitschuh.gradle.ktlint") apply false
id("com.palantir.git-version") apply false
id("com.palantir.docker") apply false
id("com.gorylenko.gradle-git-properties") apply false
id("fr.brouillard.oss.gradle.jgitver")
id("jacoco")
`maven-publish`
}
jgitver {
strategy = Strategies.PATTERN
versionPattern = "\${M}.\${m}.\${p}-\${meta.GIT_SHA1_8}\${-rc~meta.QUALIFIED_BRANCH_NAME}-SNAPSHOT"
nonQualifierBranches = "master"
policy(closureOf<JGitverPluginExtensionBranchPolicy> {
pattern = "(feature.*)"
transformations = listOf("IGNORE")
})
policy(closureOf<JGitverPluginExtensionBranchPolicy> {
pattern = "(bugfix.*)"
transformations = listOf("IGNORE")
})
policy(closureOf<JGitverPluginExtensionBranchPolicy> {
pattern = "release(.*)"
transformations = listOf("REPLACE_UNEXPECTED_CHARS_UNDERSCORE", "UPPERCASE")
})
policy(closureOf<JGitverPluginExtensionBranchPolicy> {
pattern = "(dev)"
transformations = listOf("IGNORE")
})
}
allprojects {
group = "com.taskmanagement"
version = "1.0.0-SNAPSHOT"
repositories {
mavenCentral()
mavenLocal()
}
}
subprojects {
apply(plugin = "io.spring.dependency-management")
apply(plugin = "kotlin")
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "jacoco")
apply(plugin = "maven-publish")
val jacocoCoverageFile = "$buildDir/jacocoReports/test/jacocoTestReport.xml"
tasks.withType<JacocoReport> {
reports {
xml.apply {
required.set(true)
outputLocation.set(file(jacocoCoverageFile))
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
events = setOf(
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED
)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
}
finalizedBy("jacocoTestReport")
}
val detektConfigFilePath = "$rootDir/gradle/detekt-config.yml"
tasks.withType<Detekt> {
exclude("resources/")
exclude("build/")
config.setFrom(detektConfigFilePath)
buildUponDefaultConfig = true
}
the<DependencyManagementExtension>().apply {
imports {
mavenBom("org.springframework.cloud:spring-cloud-dependencies:$springCloudVersion")
mavenBom("org.testcontainers:testcontainers-bom:$testContainers")
mavenBom("org.springframework.boot:spring-boot-dependencies:$springBootVersion") {
bomProperty("kotlin.version", kotlinVersion)
}
}
dependencies {
dependency("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
dependency("org.springdoc:springdoc-openapi-ui:$springDocOpenApiVersion")
dependency("org.springdoc:springdoc-openapi-webmvc-core:$springDocOpenApiVersion")
dependency("org.springdoc:springdoc-openapi-security:$springDocOpenApiVersion")
dependency("org.springdoc:springdoc-openapi-kotlin:$springDocOpenApiVersion")
dependency("org.springdoc:springdoc-openapi-data-rest:$springDocOpenApiVersion")
dependency("org.springframework.security.oauth:spring-security-oauth2:$springSecurityOauth2Version")
dependency("org.springframework.security:spring-security-core:$springSecurityCoreVersion")
dependency("org.flywaydb:flyway-core:$flywayVersion")
dependency("org.postgresql:postgresql:$postgresVersion")
dependency("com.vladmihalcea:hibernate-types-55:$hibernateTypesVersion")
dependency("net.logstash.logback:logstash-logback-encoder:$logstashLogbackEncoderVersion")
dependency("com.frimastudio:slf4j-kotlin-extensions:$slf4jKotlinExtensionVersion")
dependency("io.strikt:strikt-core:$striktVersion")
dependency("org.openapitools:openapi-generator-gradle-plugin:$openapiGeneratorVersion")
dependency("org.junit.platform:junit-platform-launcher:$junitPlatformLauncherVersion")
dependency("io.mockk:mockk:$mockkVersion")
dependency("com.ninja-squad:springmockk:$springMockkVersion")
}
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_11.toString()
}
}
jacoco {
toolVersion = jacocoToolVersion
reportsDirectory.set(file("$buildDir/jacocoReports"))
}
val sourcesJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles sources JAR"
archiveClassifier.set("sources")
from(project.the<SourceSetContainer>()["main"].allSource)
}
publishing {
publications {
create<MavenPublication>("maven") {
versionMapping {
usage("java-api") {
fromResolutionOf("runtimeClasspath")
}
usage("java-runtime") {
fromResolutionResult()
}
}
from(components["java"])
afterEvaluate {
artifact(sourcesJar)
}
}
}
}
afterEvaluate {
if (tasks.withType<BootJar>().isNotEmpty()) {
tasks.withType<BootJar> {
layered {}
}
val bootJar: BootJar by tasks
bootJar.apply {
archiveClassifier.set("application")
}
val explodeJar by tasks.register<JavaExec>("explodeJar") {
group = "build"
description = "Explodes layered fat jar into build/libs"
dependsOn(bootJar)
classpath(fileTree(bootJar.archiveFile))
workingDir(mkdir(bootJar.destinationDirectory.dir("exploded")))
jvmArgs("-Djarmode=layertools")
args("extract")
outputs.dir(bootJar.destinationDirectory.dir("exploded"))
}
tasks {
configure<DockerExtension> {
files(explodeJar.outputs)
dependsOn(explodeJar)
}
}
}
}
}