forked from Mantaro/MantaroBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
207 lines (173 loc) · 5.56 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
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
/*
* Copyright (C) 2016 Kodehawa
*
* Mantaro is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Mantaro is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Mantaro. If not, see http://www.gnu.org/licenses/
*
*/
plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
mainClassName = "net.kodehawa.mantarobot.MantaroBot"
def ver = new Version(major: 8, minor: 1, revision: 0)
version ver.toString()
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
repositories {
mavenCentral()
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
maven {
url 'https://jitpack.io'
}
maven {
url "https://maven.topi.wtf/releases"
}
}
task generateLanguageList {
doLast {
def out = new PrintStream(new FileOutputStream(new File(project.rootDir, "src/main/resources/assets/languages/list.txt")))
new File(project.rootDir, "src/main/resources/assets/languages").listFiles().each {
if (it.getName().endsWith("json")) {
out.println(it.getName())
}
}
out.close()
}
}
dependencies {
// Base
implementation 'net.dv8tion:JDA:5.0.0-beta.16'
implementation 'club.minnced:discord-webhooks:0.8.4'
// Music
implementation ('com.github.freyacodes:Lavalink-Client:5fe1b90ab5') {
exclude group: 'com.sedmelluq', module: 'lavaplayer'
} // Lavalink-Client includes LP, but we specify it below, so we need to exclude it.
implementation 'com.github.walkyst:lavaplayer-fork:1.4.3'
implementation "com.github.TopiSenpai.LavaSrc:lavasrc:3.2.9"
// JSON
implementation 'com.fasterxml.jackson.core:jackson-core:2.15.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.3'
// Core
implementation 'io.github.classgraph:classgraph:4.8.163'
implementation 'ch.qos.logback:logback-classic:1.4.11'
implementation 'com.google.guava:guava:32.1.3-jre'
implementation 'commons-io:commons-io:2.15.0'
implementation 'org.java-websocket:Java-WebSocket:1.5.4'
// Database
implementation 'org.mongodb:mongodb-driver-sync:4.11.0'
implementation 'redis.clients:jedis:5.0.2'
// Utilities
implementation 'org.apache.commons:commons-lang3:3.13.0'
implementation 'org.apache.commons:commons-text:1.10.0'
implementation 'com.github.Kodehawa:imageboard-api:2.6.0'
// Prometheus
implementation 'io.prometheus:simpleclient:0.9.0'
implementation 'io.prometheus:simpleclient_hotspot:0.9.0'
implementation 'io.prometheus:simpleclient_httpserver:0.9.0'
//Unit tests
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
}
// Damned Gradle 8
compileJava.dependsOn generateLanguageList
distZip.dependsOn shadowJar
distTar.dependsOn shadowJar
startScripts.dependsOn shadowJar
startShadowScripts.dependsOn jar
test.dependsOn generateLanguageList
task ci {
dependsOn shadowJar
}
def lint = [
"auxiliaryclass",
"cast",
"classfile",
"deprecation",
"dep-ann",
"divzero",
"empty",
"exports",
"fallthrough",
"finally",
"module",
"opens",
"options",
"overloads",
"overrides",
"path",
// removed because of "No processor claimed any of these annotations: ..."
//"processing",
"rawtypes",
"removal",
"requires-automatic",
"requires-transitive-automatic",
// removed because "non-transient instance field of a serializable class declared with a non-serializable type", believe me i know
//"serial",
"static",
"try",
"unchecked",
"varargs",
"preview"
]
import org.apache.tools.ant.filters.ReplaceTokens
def gitRevision() {
def gitVersion = new ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = gitVersion
}
return gitVersion.toString().trim()
}
task sourcesForRelease(type: Copy) {
from ('src/main/java') {
include '**/MantaroInfo.java'
filter(ReplaceTokens, tokens: [
version: ver.toString(),
revision: gitRevision().toString()
])
}
into 'build/filteredSrc'
includeEmptyDirs = false
}
task generateJavaSources(type: SourceTask) {
def javaSources = sourceSets.main.allJava.filter {
it.name != 'MantaroInfo.java'
}
source = javaSources + sourcesForRelease.destinationDir
dependsOn sourcesForRelease
}
compileJava {
source = generateJavaSources.source
classpath = sourceSets.main.compileClasspath
//options.compilerArgs += ["-Xlint:${lint.join(",")}", "-Werror"]
options.compilerArgs += ["-Xlint:${lint.join(",")}"]
dependsOn generateJavaSources
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.incremental = true
}
build.dependsOn shadowJar
shadowJar {
archiveClassifier.set(null)
exclude 'module-info.class'
}
class Version {
String major, minor, revision
String toString() {
"${major}.${minor}.${revision}"
}
}