-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.gradle
156 lines (135 loc) · 3.81 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
import org.apache.tools.ant.filters.ReplaceTokens
buildscript {
configurations.classpath {
resolutionStrategy.activateDependencyLocking()
}
}
plugins {
id 'idea'
id 'java'
alias(libs.plugins.gitprops)
alias(libs.plugins.spring)
id 'jacoco'
alias(libs.plugins.sonar)
alias(libs.plugins.versions)
}
group 'space.npstr.baymax'
version '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
vendor = JvmVendorSpec.ADOPTIUM
}
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
configurations {
// fucks with spring boot jar, we don't need it anyways
compile.exclude module: 'opus-java'
}
dependencies {
implementation platform(libs.spring.boot.bom)
testRuntimeOnly platform(libs.spring.boot.bom)
implementation libs.jda
implementation libs.logback
implementation libs.sentry
implementation libs.sentry.spring.starter
implementation libs.snakeyaml
implementation libs.caffeine
implementation libs.emojis
implementation libs.guava
implementation libs.sqlite
implementation libs.flyway
//spring
implementation libs.spring.boot.starter
//testing
testImplementation libs.junit.api
testRuntimeOnly libs.junit.engine
testRuntimeOnly libs.junit.launcher
}
dependencyUpdates.resolutionStrategy {
componentSelection properReleasesOnly()
}
dependencyLocking {
lockAllConfigurations()
}
// ./gradlew resolveAndLockAll --write-locks
task resolveAndLockAll {
doFirst {
assert gradle.startParameter.writeDependencyLocks
}
doLast {
configurations.all {
resolutionStrategy {
componentSelection properReleasesOnly()
}
}
configurations
.findAll { it.canBeResolved }
.each { it.resolve() }
}
}
tasks.withType(JavaCompile) {
dependsOn(clean, processResources)
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
bootRun {
//compiling tests during bootRun increases the likelyhood of catching broken tests locally instead of on the CI
dependsOn compileTestJava
//pass in custom jvm args
// source: https://stackoverflow.com/a/25079415
// example: ./gradlew bootRun -PjvmArgs="--illegal-access=debug -Dwhatever=value"
if (project.hasProperty('jvmArgs')) {
//noinspection GroovyAssignabilityCheck
jvmArgs project.jvmArgs.split('\\s+')
}
}
bootJar {
archiveFileName.set("baymax.jar")
doLast {
copy {
from 'build/libs/baymax.jar'
into '.'
}
}
}
test {
useJUnitPlatform()
jacoco {
includes['space.npstr.baymax.*']
}
}
sonarqube {
properties {
property 'sonar.inclusions', 'src/main/java/space/npstr/baymax/**/*'
}
}
processResources {
//inject values into app.properties
filesMatching("**/app.properties") {
filter ReplaceTokens, tokens: [
"project.version" : project.version,
"project.groupId" : project.group,
"project.artifactId": project.name,
"env.BUILD_NUMBER" : (System.getenv('CI') ? System.getenv('BUILD_NUMBER') : 'DEV'),
"env.BUILD_TIME" : System.currentTimeMillis() + ''
]
}
}
static def properReleasesOnly() {
return { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = [
'alpha', 'beta', 'rc', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'preview',
].any {
q -> selection.candidate.version.toLowerCase().contains(q) && !selection.candidate.module.equals("JDA")
}
if (rejected) {
selection.reject('Not a release')
}
}
}
}