-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
135 lines (122 loc) · 3.8 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.cloud.contract.verifier.config.TestFramework.JUNIT5
import org.springframework.cloud.contract.verifier.config.TestMode.WEBTESTCLIENT
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
val commonsVersion: String by project
val imageName = "springboot-users"
val gcloudProjectId = System.getenv("GCP_PROJECT_ID") ?: "gcloud-equidis"
plugins {
idea
`maven-publish`
jacoco
id("org.springframework.boot") version "2.4.5"
id("org.springframework.cloud.contract") version "3.0.2"
id("com.google.cloud.tools.jib") version "3.0.0"
kotlin("jvm") version "1.4.32"
kotlin("plugin.spring") version "1.4.32"
}
group = "com.github.jntakpe"
version = "0.1.7"
java.sourceCompatibility = JavaVersion.VERSION_11
repositories {
mavenLocal()
mavenCentral()
jcenter()
mavenGithub("equidis/sb-commons")
}
dependencies {
implementation("com.github.jntakpe:sb-commons-cache:$commonsVersion")
implementation("com.github.jntakpe:sb-commons-management:$commonsVersion")
implementation("com.github.jntakpe:sb-commons-mongo:$commonsVersion")
implementation("com.github.jntakpe:sb-commons-tracing:$commonsVersion")
implementation("com.github.jntakpe:sb-commons-web:$commonsVersion")
testImplementation("com.github.jntakpe:sb-commons-cache-test:$commonsVersion")
testImplementation("com.github.jntakpe:sb-commons-mongo-test:$commonsVersion")
testImplementation("com.github.jntakpe:sb-commons-test:$commonsVersion")
testImplementation("com.github.jntakpe:sb-commons-web-test:$commonsVersion")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}
jib {
to {
image = "eu.gcr.io/$gcloudProjectId/$imageName:${project.version}"
}
from {
image = "gcr.io/distroless/java:11"
}
}
tasks {
jacocoTestReport {
dependsOn(test)
reports {
xml.isEnabled = true
}
classDirectories.setFrom(
sourceSets.main.get().output.asFileTree.matching {
exclude("build/generated", "**/model/entity/**")
}
)
}
check {
dependsOn(jacocoTestReport)
}
val metadataPath = Paths.get("$buildDir/build-metadata.yaml")
val deploymentZip = register<Zip>("deploymentZip") {
archiveFileName.set("deployment-metadata.zip")
destinationDirectory.set(Paths.get(buildDir.toString(), "libs").toFile())
from(metadataPath.toString())
}
bootJar {
doLast {
if (!Files.exists(metadataPath)) Files.createFile(metadataPath)
Files.writeString(
metadataPath,
"""
app:
name: users
version: ${project.version}
kind: http
dependencies:
mongodb: true
redis: true
image:
name: $imageName
""".trimIndent(), StandardOpenOption.SYNC
)
}
}
assemble {
dependsOn(deploymentZip)
}
}
contracts {
setTestFramework(JUNIT5)
setTestMode(WEBTESTCLIENT)
setFailOnNoContracts(false)
setBasePackageForTests("com.github.jntakpe.sbusers")
setBaseClassForTests("com.github.jntakpe.commons.web.test.ContractBaseClass")
}
publishing {
repositories {
mavenGithub("equidis/spring-boot-users-service")
}
}
fun RepositoryHandler.mavenGithub(repository: String) = maven {
name = "Github_packages"
setUrl("https://maven.pkg.github.com/$repository")
credentials {
val githubActor: String? by project
val githubToken: String? by project
username = githubActor
password = githubToken
}
}