-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
162 lines (142 loc) · 4.09 KB
/
build.gradle
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
buildscript {
configurations.classpath {
resolutionStrategy.activateDependencyLocking()
}
}
plugins {
id "java-library"
id "org.jetbrains.kotlin.jvm"
id "com.github.ben-manes.versions"
id "org.jetbrains.kotlin.kapt"
id "org.jetbrains.kotlin.plugin.spring" // opens certain classes
id "jacoco"
id "org.sonarqube"
id "maven-publish"
}
group = "dev.capybaralabs.shipa"
version = "$shipaVersion"
allprojects {
java {
toolchain {
languageVersion = JavaLanguageVersion.of(theJavaVersion)
vendor = JvmVendorSpec.ADOPTIUM
}
withSourcesJar()
consistentResolution {
useCompileClasspathVersions()
}
}
tasks.withType(JavaCompile).configureEach {
dependsOn(processResources)
options.encoding = "UTF-8"
options.release.set(theJavaVersion.toInteger())
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-Xmaxerrs" << "10000" << "-Xdiags:verbose"
options.incremental = true
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions.jvmTarget = theJavaVersion
compilerOptions.freeCompilerArgs.addAll("-java-parameters", "-Werror")
}
repositories {
mavenCentral()
}
}
dependencies {
api platform(libs.kotlin.bom)
api platform(libs.spring.boot.bom)
kapt platform(libs.spring.boot.bom)
api platform(libs.sentry.bom)
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
api "org.jetbrains.kotlin:kotlin-reflect"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8"
api "org.springframework.boot:spring-boot-starter"
api "org.springframework.boot:spring-boot-starter-web"
api "io.micrometer:micrometer-registry-prometheus"
api "com.fasterxml.jackson.module:jackson-module-kotlin"
implementation "io.sentry:sentry-kotlin-extensions"
implementation libs.saltycoffee
implementation "com.github.ben-manes.caffeine:caffeine"
kapt "org.springframework.boot:spring-boot-configuration-processor"
}
dependencyLocking {
lockAllConfigurations()
}
// ./gradlew resolveAndLockAll --write-locks
tasks.register("resolveAndLockAll") {
doFirst {
assert gradle.startParameter.writeDependencyLocks
}
doLast {
configurations.configureEach {
resolutionStrategy {
componentSelection properReleasesOnly()
}
}
configurations
.findAll { it.canBeResolved }
.each { it.resolve() }
}
}
tasks.named("dependencyUpdates").configure {
resolutionStrategy {
componentSelection properReleasesOnly()
}
checkConstraints = true
checkBuildEnvironmentConstraints = true
gradleReleaseChannel = "current"
}
static def properReleasesOnly() {
return { rules ->
rules.all { ComponentSelection selection ->
if (isNonStable(selection.candidate.version) && (selection.hasProperty("currentVersion") && !isNonStable(selection.currentVersion))) {
reject("Release candidate")
}
}
}
}
static def isNonStable(String version) {
def stableKeyword = ["RELEASE", "FINAL", "GA"].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
// See https://github.com/gradle/gradle/issues/8881#issuecomment-593227192
tasks.register("codeCoverageReport", JacocoReport) {
dependsOn(test, ":example:test")
// Gather execution data from all subprojects
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")
// Add all relevant sourcesets from the subprojects
subprojects.each {
sourceSets it.sourceSets.main
}
reports {
xml.required.set(true)
html.required.set(true)
csv.required.set(false)
}
}
tasks.withType(org.sonarqube.gradle.SonarTask).configureEach {
dependsOn codeCoverageReport
}
sonarqube {
properties {
property "sonar.projectKey", "dev.capybaralabs.shipa"
property "sonar.coverage.jacoco.xmlReportPaths", "${rootDir}/build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml"
property "sonar.coverage.exclusions", "example/**/*"
}
}
publishing {
publications {
create("main", MavenPublication) {
from(components.kotlin)
}
}
}
jar {
manifest {
attributes(
'Implementation-Title': "CapybaraLabs Shipa",
'Implementation-Version': "$project.version",
)
}
}