-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbuild.gradle
More file actions
300 lines (257 loc) · 7.96 KB
/
build.gradle
File metadata and controls
300 lines (257 loc) · 7.96 KB
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.kohsuke.github.*
import java.nio.file.Files
import java.time.OffsetDateTime
import java.time.ZoneOffset
import java.time.format.DateTimeFormatter
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.kohsuke:github-api:1.315'
}
}
plugins {
id 'application'
// id 'maven'
id 'eclipse'
id 'idea'
id 'checkstyle'
alias(libs.plugins.shadow)
alias(libs.plugins.flyway)
alias(libs.plugins.licenser)
alias(libs.plugins.lombok)
}
ext {
bySourceSetConfigurations = new HashMap<SourceSet, Configuration>()
BOTS = [
'watcher', 'listener', 'commander', 'painter'
]
}
group 'com.mcmoddev'
version project.bot_version
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
println "Bot Version: $version"
println "Bots: ${String.join(" ", BOTS)}"
final var actualDateTime = OffsetDateTime.now(ZoneOffset.UTC).withNano(0)
application {
mainClass = 'com.mcmoddev.mmdbot.core.RunBots'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs = [
'-Xlint:all', // deprecation, rawtypes, cast, unchecked, all
//'-Xdiags:verbose',
//'-Werror'
]
compileJava.options.compilerArgs += '-proc:none'
}
sourceSets {
core {}
}
configurations {
global
coreImplementation.extendsFrom(global)
testImplementation.extendsFrom(global)
globalCompile
coreCompileOnly.extendsFrom(globalCompile)
testCompileOnly.extendsFrom(globalCompile)
}
void createBot(String name) {
final SourceSet s = sourceSets.create(name)
configurations {
create(name)
getByName("${name}Implementation").extendsFrom(getByName(name))
getByName("${name}Implementation").extendsFrom(global)
getByName("${name}CompileOnly").extendsFrom(globalCompile)
coreRuntimeOnly.extendsFrom(getByName(name))
}
dependencies {
"${name}" sourceSets.core.output
coreRuntimeOnly s.output
}
bySourceSetConfigurations.put(s, configurations.getByName(name))
configureBotJar(name, s)
}
BOTS.forEach(this::createBot)
configurations {
shade
implementation.extendsFrom(shade)
}
repositories {
mavenCentral()
maven {
name 'jda-chewtils'
url 'https://m2.chew.pro/snapshots'
}
maven {
url "https://clojars.org/repo/"
}
maven { url 'https://jitpack.io' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
coreRuntimeOnly sourceSets.main.output
globalCompile project(':relauncher')
global(libs.jda) {
exclude module: 'jackson-databind' // their jackson version is outdated
}
global libs.chewtils
global libs.guava
global libs.gson
global libs.logback
global libs.sqlite
global libs.flyway
global libs.reflections
global libs.dotenv
global libs.fastutil
global libs.configurate.hocon
global libs.eventdispatcher
global libs.asmutils
global libs.typetools
global libs.caffeine
global libs.urldetector
global libs.cfapi
global libs.webhooks
global libs.jopt
global libs.jdbi.core
global libs.jdbi.sqlobject
commander libs.jsoup
commander libs.javadocapi
commander libs.graal
commander libs.graal.scriptengine
// TODO remove
watcher libs.nightconfig
globalCompile libs.lombok
globalCompile libs.jsr305
globalCompile libs.annotations
testImplementation libs.junit
testImplementation libs.mockito
testImplementation sourceSets.core.output
testImplementation sourceSets.watcher.output
}
// Relocates all of the tasks from build
tasks.configureEach {
if (it.group == 'build') it.group = 'other'
}
tasks.named('build').configure { it.group = 'build' }
tasks.named('updateLicenses').configure { it.group = 'licensing' }
tasks.named('licenseFormat').configure { group = 'licensing' }
tasks.named('run', JavaExec).configure {
workingDir = new File('run')
}
tasks.named('test', Test).configure {
workingDir = java.nio.file.Path.of('run/tests').toFile()
}
tasks.named('shadowJar', ShadowJar).configure {
sourceSets.each {
from it.output
}
configurations = [project.configurations.global]
configurations.addAll(bySourceSetConfigurations.values())
manifest.attributes(makeManifestAttributes(application.getMainClass().get()))
archiveClassifier.set 'all'
group 'build'
description 'Builds the whole project with its dependencies.'
dependsOn tasks.named('updateLicenses')
}
tasks.named(JavaPlugin.JAR_TASK_NAME, Jar).configure {
from sourceSets.main.output
from sourceSets.core.output
manifest.attributes(makeManifestAttributes(application.getMainClass().get()))
archiveClassifier.set 'core-no-deps'
description 'Builds the core sourceSet without its dependencies.'
dependsOn tasks.named('updateLicenses')
}
void configureBotJar(String botName, SourceSet sourceSet) {
tasks.register("${botName}Jar", ShadowJar) {
from sourceSets.main.output
from sourceSets.core.output
from sourceSet.output
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
archiveClassifier.set(botName)
manifest.attributes(makeManifestAttributes('com.mcmoddev.mmdbot.core.OnlyOneBotRunner'))
configurations.add(project.configurations.global)
configurations.add((Configuration) bySourceSetConfigurations.get(sourceSet))
group 'build'
description "Builds the bot $botName and its dependencies."
dependsOn tasks.named('updateLicenses')
}
tasks.register("${botName}JarNoDeps", Jar) {
from sourceSets.main.output
from sourceSets.core.output
from sourceSet.output
archiveClassifier.set "${botName}-no-deps"
manifest.attributes(makeManifestAttributes('com.mcmoddev.mmdbot.core.OnlyOneBotRunner'))
group 'build'
description "Builds the bot $botName without its dependencies."
dependsOn tasks.named('updateLicenses')
}
}
Map makeManifestAttributes(String mainClass) {
final var actualDateTime = OffsetDateTime.now(ZoneOffset.UTC).withNano(0)
final var currentDateTime = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(actualDateTime)
return [
'Maven-Artifact' : "${project.group}:${archivesBaseName}:${project.bot_version}",
'Timestamp' : currentDateTime,
'Specification-Title' : archivesBaseName,
'Specification-Vendor' : 'Minecraft Mod Development',
'Specification-Version' : '1',
'Implementation-Title' : archivesBaseName,
'Implementation-Version' : "${project.bot_version}",
'Implementation-Vendor' : 'Minecraft Mod Development',
'Implementation-Timestamp': currentDateTime,
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On' : "${project.libs.versions.jda.get()}-${project.libs.versions.chewtils.get()}",
'Main-Class' : mainClass
]
}
license {
ignoreFailures = true // Temporarily downgrade license header violations to warnings, because in-flux development
header = project.file('LicenseHeader.md')
include '**/*.java'
include '**/*.kt'
exclude '**/package-info.java'
exclude '**/module-info.java'
newLine = false
properties {
year = actualDateTime.getYear()
}
}
eclipse.project {
buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
natures 'org.eclipse.buildship.core.gradleprojectnature'
}
idea.module {
downloadJavadoc = true
inheritOutputDirs = true
}
tasks.withType(Javadoc).configureEach {
failOnError = false
}
tasks.named('test') {
useJUnitPlatform()
testLogging {
events 'passed', 'skipped', 'failed'
}
}
flyway {
url = 'jdbc:sqlite:./data.db'
user = 'sa'
}
checkstyle {
ignoreFailures = true
toolVersion = '10.12.2'
showViolations = false
}
tasks.withType(Checkstyle).configureEach {
reports {
xml.required = true
html.required = true
// html.stylesheet resources.text.fromFile('config/xsl/checkstyle-noframes.xsl') // Default
html.stylesheet resources.text.fromFile('config/xsl/checkstyle-noframes-severity-sorted.xsl')
}
}