forked from cc-tweaked/cc-restitched
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
363 lines (292 loc) · 9.58 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
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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
plugins {
id "checkstyle"
id "jacoco"
id "maven-publish"
id "com.github.hierynomus.license" version "0.16.1"
id "org.jetbrains.kotlin.jvm" version "1.6.0"
id 'fabric-loom' version '0.11-SNAPSHOT'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
}
def javaVersion = JavaLanguageVersion.of(17)
java {
toolchain {
languageVersion = javaVersion
}
withSourcesJar()
withJavadocJar()
}
tasks.withType(JavaExec).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = javaVersion
}
}
version = mod_version
group = "dan200.computercraft"
archivesBaseName = "cc-restitched"
sourceSets {
main.resources {
srcDir 'src/generated/resources'
}
testMod {}
}
loom {
accessWidenerPath = file("src/main/resources/cc.accesswidener")
runs {
data {
server()
name "Data Generation"
vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${file("src/generated/resources")}"
runDir "build/datagen"
}
}
}
repositories {
mavenCentral()
maven {
name "SquidDev"
url "https://squiddev.cc/maven"
}
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
maven {
name = "NucleoidMC"
url = "https://maven.nucleoid.xyz"
content {
includeGroup "eu.pb4"
}
}
// TODO: Limit these to a set of groups.
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/" }
}
configurations {
shade
implementation.extendsFrom shade
cctJavadoc
}
dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:8.45"
minecraft "com.mojang:minecraft:${mc_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"
modImplementation "com.terraformersmc:modmenu:${modmenu_version}"
modImplementation "io.netty:netty-codec-http:${netty_http_version}"
modCompileOnly "eu.pb4:common-protection-api:1.0.0"
implementation 'com.electronwill.night-config:toml:3.6.3'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
modImplementation 'org.squiddev:Cobalt:0.5.5'
include 'com.electronwill.night-config:core:3.6.3'
include 'com.electronwill.night-config:toml:3.6.3'
include "io.netty:netty-codec-http:${netty_http_version}"
include('org.squiddev:Cobalt:0.5.5')
//modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-api-fabric:6.0.254-alpha"
//modRuntimeOnly "me.shedaniel:RoughlyEnoughItems-fabric:6.0.254-alpha"
modCompileOnly "maven.modrinth:iris:1.19.x-v1.2.5"
// For running with Iris. Can be ignored most of the time.
// modRuntimeOnly "maven.modrinth:iris:1.19.x-v1.2.5"
// modRuntimeOnly "maven.modrinth:sodium:mc1.19-0.4.2"
// runtimeOnly "org.joml:joml:1.10.2"
// runtimeOnly "org.anarres:jcpp:1.4.14"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0'
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.0'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.5'
}
processResources {
inputs.property "version", project.version
def hash = 'none'
Set<String> contributors = []
try {
hash = ["git", "-C", projectDir, "rev-parse", "HEAD"].execute().text.trim()
def blacklist = ['GitHub', 'Daniel Ratcliffe', 'Weblate']
// Extract all authors, commiters and co-authors from the git log.
def authors = ["git", "-C", projectDir, "log", "--format=tformat:%an <%ae>%n%cn <%ce>%n%(trailers:key=Co-authored-by,valueonly)"]
.execute().text.readLines().unique()
// We now pass this through git's mailmap to de-duplicate some authors.
def remapAuthors = ["git", "check-mailmap", "--stdin"].execute()
remapAuthors.withWriter { stdin ->
if (stdin !instanceof BufferedWriter) stdin = new BufferedWriter(stdin)
authors.forEach {
if (it == "") return
if (!it.endsWith(">")) it += ">" // Some commits have broken Co-Authored-By lines!
stdin.writeLine(it)
}
stdin.close()
}
// And finally extract out the actual name.
def emailRegex = ~/^([^<]+) <.+>$/
remapAuthors.text.readLines().forEach {
def matcher = it =~ emailRegex
matcher.find()
def name = matcher.group(1)
if (!blacklist.contains(name)) contributors.add(name)
}
} catch (Exception e) {
e.printStackTrace()
}
inputs.property "commithash", hash
duplicatesStrategy = DuplicatesStrategy.INCLUDE
filesMatching(["fabric.mod.json", "data/computercraft/lua/rom/help/credits.txt"]) {
expand(
'version': mod_version,
'mcversion': mc_version,
'gitcontributors': contributors.sort(false, String.CASE_INSENSITIVE_ORDER).join('\n')
)
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
javadoc {
include "dan200/computercraft/api/**/*.java"
}
task luaJavadoc(type: Javadoc) {
description "Generates documentation for Java-side Lua functions."
group "documentation"
source = sourceSets.main.allJava
destinationDir = file("${project.docsDir}/luaJavadoc")
classpath = sourceSets.main.compileClasspath
options.docletpath = configurations.cctJavadoc.files as List
options.doclet = "cc.tweaked.javadoc.LuaDoclet"
options.noTimestamp = false
javadocTool = javaToolchains.javadocToolFor {
languageVersion = javaVersion
}
}
jar {
from "LICENSE"
manifest {
attributes([
"Specification-Title" : "computercraft",
"Specification-Version" : "1",
"Implementation-Title" : "CC: Restitched",
"Implementation-Version" : "${mod_version}",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}
[compileJava, compileTestJava].forEach {
it.configure {
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
}
}
sourcesJar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
// Check tasks
test {
useJUnitPlatform()
testLogging {
events "skipped", "failed"
}
}
jacocoTestReport {
dependsOn('test')
reports {
xml.required = true
html.required = true
}
}
check.dependsOn jacocoTestReport
import com.hierynomus.gradle.license.tasks.LicenseCheck
import com.hierynomus.gradle.license.tasks.LicenseFormat
license {
mapping("java", "SLASHSTAR_STYLE")
strictCheck true
ext.year = Calendar.getInstance().get(Calendar.YEAR)
}
[licenseMain, licenseFormatMain].forEach {
it.configure {
include("**/*.java")
exclude("dan200/computercraft/api/**")
header file('config/license/main.txt')
}
}
[licenseTest, licenseFormatTest, licenseTestMod, licenseFormatTestMod].forEach {
it.configure {
include("**/*.java")
header file('config/license/main.txt')
}
}
gradle.projectsEvaluated {
tasks.withType(LicenseFormat) {
outputs.upToDateWhen { false }
}
}
task licenseAPI(type: LicenseCheck)
task licenseFormatAPI(type: LicenseFormat)
[licenseAPI, licenseFormatAPI].forEach {
it.configure {
source = sourceSets.main.java
include("dan200/computercraft/api/**")
header file('config/license/api.txt')
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
if (System.getenv("MODRINTH")) {
modrinth {
token = System.getenv("MODRINTH")
projectId = "eldBwa5V"
versionName = "[" + ((String) project.mc_version) + "] " + version
versionNumber = "" + version + "+" + ((String) project.mc_version)
versionType = "release"
uploadFile = remapJar
gameVersions = [((String) project.mc_version)]
loaders = ["fabric", "quilt"]
changelog = System.getenv("CHANGELOG")
}
remapJar {
finalizedBy project.tasks.modrinth
}
}
if (System.getenv("CURSEFORGE")) {
curseforge {
apiKey = System.getenv("CURSEFORGE")
project {
id = "462672"
releaseType = "release"
changelog = System.getenv("CHANGELOG")
changelogType = "markdown"
addGameVersion ((String) project.mc_version)
addGameVersion "Fabric"
addGameVersion "Quilt"
mainArtifact(remapJar) {
displayName = "[" + ((String) project.mc_version) + "] " + version
}
afterEvaluate {
uploadTask.dependsOn("remapJar")
}
}
options {
forgeGradleIntegration = false
}
}
remapJar {
finalizedBy project.tasks.curseforge
}
}