forked from AkmalFairuz/PowerNukkitX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
234 lines (205 loc) · 6.25 KB
/
build.gradle.kts
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
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
plugins {
`java-library`
`maven-publish`
idea
jacoco
id("io.github.goooler.shadow") version "8.1.7"
id("io.freefair.lombok") version "8.4"
id("com.gorylenko.gradle-git-properties") version "2.4.1"
}
group = "cn.powernukkitx"
version = "2.0.0-SNAPSHOT"
description = "powernukkitx"
java.sourceCompatibility = JavaVersion.VERSION_17
repositories {
mavenLocal()
mavenCentral()
maven("https://repo.maven.apache.org/maven2/")
maven("https://jitpack.io")
maven("https://repo.opencollab.dev/maven-releases/")
maven("https://repo.opencollab.dev/maven-snapshots/")
}
dependencies {
api(libs.bundles.netty)
api(libs.bundles.logging)
api(libs.annotations)
api(libs.jsr305)
api(libs.gson)
api(libs.guava)
api(libs.commonsio)
api(libs.fastutil)
api(libs.leveldbjni)
api(libs.snakeyaml)
api(libs.stateless4j)
implementation(libs.rng.simple)
implementation(libs.rng.sampling)
implementation(libs.asm)
implementation(libs.jose4j)
implementation(libs.joptsimple)
implementation(libs.sentry)
implementation(libs.sentry.log4j2)
implementation(libs.disruptor)
implementation(libs.oshi)
implementation(libs.fastreflection)
implementation(libs.terra)
implementation(libs.bundles.compress)
implementation(libs.bundles.terminal)
implementation(libs.graalvm.polyglot)
implementation(libs.okaeri)
runtimeOnly(libs.bundles.graalvm.runtime)
testImplementation(libs.bundles.test)
testImplementation(libs.commonsio)
testImplementation(libs.commonslang3)
compileOnly(libs.lombok)
annotationProcessor(libs.lombok)
testCompileOnly(libs.lombok)
testAnnotationProcessor(libs.lombok)
}
java {
withSourcesJar()
withJavadocJar()
}
//Automatically download dependencies source code
idea {
module {
isDownloadSources = true
isDownloadJavadoc = false
}
}
sourceSets {
main {
resources {
srcDirs("src/main/js", "src/main/resources")
}
}
}
tasks.register<DefaultTask>("buildFast") {
dependsOn(tasks.build)
group = "alpha build"
tasks["delombok"].enabled = false
tasks["javadoc"].enabled = false
tasks["javadocJar"].enabled = false
tasks["sourcesJar"].enabled = false
tasks["copyDependencies"].enabled = false
tasks["shadowJar"].enabled = false
tasks["compileTestJava"].enabled = false
tasks["processTestResources"].enabled = false
tasks["testClasses"].enabled = false
tasks["test"].enabled = false
tasks["check"].enabled = false
}
tasks.register<DefaultTask>("buildSkipChores") {
dependsOn(tasks.build)
group = "alpha build"
tasks["delombok"].enabled = false
tasks["javadoc"].enabled = false
tasks["javadocJar"].enabled = false
tasks["sourcesJar"].enabled = false
tasks["compileTestJava"].enabled = false
tasks["processTestResources"].enabled = false
tasks["testClasses"].enabled = false
tasks["test"].enabled = false
tasks["check"].enabled = false
}
tasks.register<DefaultTask>("buildForGithubAction") {
dependsOn(tasks.build)
group = "build"
tasks["delombok"].enabled = false
tasks["javadoc"].enabled = false
tasks["javadocJar"].enabled = false
}
tasks.build {
dependsOn(tasks.shadowJar)
group = "alpha build"
}
tasks.clean {
group = "alpha build"
delete("nukkit.yml", "terra", "services")
}
tasks.compileJava {
options.encoding = "UTF-8"
options.compilerArgs.add("-Xpkginfo:always")
java.sourceCompatibility = JavaVersion.VERSION_21
java.targetCompatibility = JavaVersion.VERSION_21
}
tasks.test {
useJUnitPlatform()
jvmArgs(listOf("--add-opens", "java.base/java.lang=ALL-UNNAMED"))
jvmArgs(listOf("--add-opens", "java.base/java.io=ALL-UNNAMED"))
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
reports {
csv.required = false
xml.required = true
html.required = false
}
dependsOn(tasks.test) // tests are required to run before generating the report
}
tasks.withType<AbstractCopyTask>() {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.named<AbstractArchiveTask>("sourcesJar") {
destinationDirectory = layout.buildDirectory
}
tasks.jar {
destinationDirectory = layout.buildDirectory
doLast {//execution phase
val f: RegularFile = archiveFile.get()
val tf: RegularFile = layout.buildDirectory.file("${project.description}.jar").get()
Files.copy(Path.of(f.asFile.absolutePath), Path.of(tf.asFile.absolutePath), StandardCopyOption.REPLACE_EXISTING)
}
}
tasks.shadowJar {
dependsOn("copyDependencies")
manifest {
attributes(
"Main-Class" to "cn.nukkit.JarStart"
)
}
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer::class.java) //required to fix shadowJar log4j2 issue
destinationDirectory = layout.buildDirectory
}
tasks.register<Copy>("copyDependencies") {
dependsOn(tasks.jar)
group = "other"
description = "Copy all dependencies to libs folder"
from(configurations.runtimeClasspath)
into(layout.buildDirectory.dir("libs"))
}
tasks.javadoc {
options.encoding = StandardCharsets.UTF_8.name()
includes.add("**/**.java")
val javadocOptions = options as CoreJavadocOptions
javadocOptions.addStringOption(
"source",
java.sourceCompatibility.toString()
)
// Suppress some meaningless warnings
javadocOptions.addStringOption("Xdoclint:none", "-quiet")
}
publishing {
publications.create<MavenPublication>("maven") {
from(components["java"])
pom {
repositories {
mavenLocal()
mavenCentral()
maven("https://repo.maven.apache.org/maven2/")
maven("https://jitpack.io")
maven("https://repo.opencollab.dev/maven-releases/")
maven("https://repo.opencollab.dev/maven-snapshots/")
}
}
}
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<Javadoc> {
options.encoding = "UTF-8"
}