-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
237 lines (210 loc) · 7.34 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
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
/*
* Copyright (c) 2018-2020 Karlatemp. All rights reserved.
* @author Karlatemp <[email protected]> <https://github.com/Karlatemp>
*
* LuckPerms-Mirai/LuckPerms-Mirai/build.gradle
*
* Use of this source code is governed by the GNU AFFERO GENERAL PUBLIC LICENSE version 3 license that can be found via the following link.
*
* https://github.com/Karlatemp/LuckPerms-Mirai/blob/master/LICENSE
*/
import java.nio.file.Files
plugins {
id 'java'
id 'java-library'
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}
def lpVersion = ({
def resu
gradle.includedBuild("LuckPerms").properties.availableModules.each { module ->
ModuleVersionIdentifier m = module.left()
if (m.name == 'common') {
resu = m.version
}
}
return resu
})().toString()
def getGitVersion = { String path ->
def proc = new ProcessBuilder("git", "rev-parse", "HEAD")
.directory(new File(rootProject.projectDir, path))
.start()
proc.waitFor()
def line = proc.inputStream.withReader { it.readLine() }
return line
}
def gitVersion = getGitVersion(".")
def gitLpVersion = getGitVersion("LuckPerms")
def now = System.currentTimeMillis()
println("GitVersion = $gitVersion")
println("LpGVersion = $gitLpVersion")
// [LP-Mirai version]-[LuckPerms version]
def lpMiraiVer = '2.14.0-dev-8'
def ver = lpMiraiVer + '+' + lpVersion
allprojects {
group 'io.github.karlatemp.mirai.luckperms'
if (name == 'public-api') {
version lpMiraiVer
} else {
version ver
}
repositories {
mavenLocal()
mavenCentral()
}
afterEvaluate {
compileKotlin {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += [
'-Xopt-in=kotlin.RequiresOptIn',
'-Xopt-in=io.github.karlatemp.luckperms.mirai.openapi.anno.InternalLpApi',
'-Xopt-in=io.github.karlatemp.luckperms.mirai.openapi.anno.ExperimentalLpApi',
'-Xjvm-default=enable'
]
}
}
}
}
dependencies {
// https://mvnrepository.com/artifact/io.github.karlatemp/unsafe-accessor
implementation group: 'io.github.karlatemp', name: 'unsafe-accessor', version: '1.4.0'
// https://mvnrepository.com/artifact/org.fusesource.jansi/jansi
compileOnly group: 'org.fusesource.jansi', name: 'jansi', version: '1.18'
api 'org.spongepowered:configurate-hocon:3.7.1'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
api group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
api "me.lucko.luckperms:common" // LuckPerms
api project(':public-api')
compileOnly(project.property('versions.mirai-core-api'))
compileOnly(project.property('versions.mirai-console'))
//
// ({
// def console = rootProject.file("../Mirai-console/backend/mirai-console/build/libs")
// if (console.isDirectory() && console.listFiles().length > 0) {
// compileOnly(fileTree(console))
// compileOnly("com.vdurmont:semver4j:3.1.0")
// } else {
// compileOnly("net.mamoe:mirai-console:1.0-M4-dev-3") // 后端
// }
// })()
compileOnly "org.jetbrains.kotlin:kotlin-stdlib"
testApi group: 'junit', name: 'junit', version: '4.12'
}
processResources {
from(sourceSets.main.resources.srcDirs) {
expand([
'pluginVersion': ver,
'lpVersion' : lpVersion,
'lpmVersion' : lpMiraiVer,
'gitLuckPerms' : gitLpVersion,
'gitPlugin' : gitVersion,
'buildTime' : now
])
include 'plugin.yml'
include 'metainfo.conf'
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
shadowJar {
exclude 'module-info.class'
relocate 'io.github.karlatemp.unsafeaccessor', 'me.lucko.luckperms.lib.unsafeaccessor'
relocate 'net.kyori.adventure', 'me.lucko.luckperms.lib.adventure'
relocate 'net.kyori.event', 'me.lucko.luckperms.lib.eventbus'
relocate 'com.github.benmanes.caffeine', 'me.lucko.luckperms.lib.caffeine'
relocate 'okio', 'me.lucko.luckperms.lib.okio'
relocate 'okhttp3', 'me.lucko.luckperms.lib.okhttp3'
relocate 'net.bytebuddy', 'me.lucko.luckperms.lib.bytebuddy'
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
relocate 'redis.clients.jedis', 'me.lucko.luckperms.lib.jedis'
relocate 'org.apache.commons.pool2', 'me.lucko.luckperms.lib.commonspool2'
relocate 'com.rabbitmq', 'me.lucko.luckperms.lib.rabbitmq'
// relocate 'ninja.leaping.configurate', 'me.lucko.luckperms.lib.configurate'
def excludes = [
'com.zaxxer:HikariCP',
'org.slf4j',
'me.lucko:adventure-api',
'net.bytebuddy',
'net.kyori',
'org.spongepowered:configurate-yaml',
'org.yaml:snakeyaml',
'redis.clients',
'com.github.ben-manes.caffeine',
'com.squareup.okhttp3',
'com.squareup.okio',
'me.lucko.configurate',
'org.mongodb',
'org.apache.commons'
]
dependencyFilter.exclude {
excludes.contains(it.moduleGroup + ":" + it.moduleName) || excludes.contains(it.moduleGroup)
}
}
task releaseCiJar() {
group = "build"
dependsOn(shadowJar)
doFirst {
def file = shadowJar.archiveFile.get().asFile
def target = rootProject.file("build/ci")
target.mkdirs()
def targetFile = new File(target, "luckperms-mirai.jar")
targetFile.delete()
file.withInputStream { stream ->
Files.copy(stream, targetFile.toPath())
}
}
}
task ts47() {
}
compileKotlin {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += ['-Xopt-in=kotlin.RequiresOptIn',
'-Xjvm-default=enable']
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = '1.8'
freeCompilerArgs += ['-Xopt-in=kotlin.RequiresOptIn',
'-Xjvm-default=enable']
}
}
task genPatch() {
group = "patchs"
doLast {
def code = new ProcessBuilder(
"git", "diff", "--output", "../patchs.patch"
)
.directory(project.file("LuckPerms"))
.inheritIO()
.start()
.waitFor()
if (code != 0) {
throw new IllegalStateException("Code: $code")
}
}
}
task applyPatch() {
group = "patchs"
doLast {
def proc = new ProcessBuilder(
"git", "apply", "--reject", "../patchs.patch"
)
.directory(project.file("LuckPerms"))
.inheritIO()
.start()
proc.in.eachLine { println it }
proc.err.eachLine { System.err.println it }
def code = proc.waitFor()
if (code != 0) {
throw new IllegalStateException("Code: $code")
}
}
}