-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
405 lines (351 loc) · 13.8 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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
plugins {
id 'net.neoforged.gradle.userdev' version '7.0.145'
id 'net.darkhax.curseforgegradle' version '1.0.8'
id 'com.github.kt3k.coveralls' version '2.12.0'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'com.modrinth.minotaur' version '2.+'
}
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'jacoco'
// All jar files from this folder will be added automatically as runtime mod dependencies (inspired by AE2's build.gradle)
def extraModsDir = "extra-mods"
import net.neoforged.gradle.common.tasks.PotentiallySignJar
// Determine build number
String build_number = "DEV" // this will be referenced as simply build_number from now on.
if (System.getenv().BUILD_NUMBER)
build_number = System.getenv().BUILD_NUMBER
if (System.getenv().TRAVIS_BUILD_NUMBER)
build_number = System.getenv().TRAVIS_BUILD_NUMBER
if (System.getenv().GITHUB_RUN_ID)
build_number = System.getenv().GITHUB_RUN_NUMBER
if (System.getenv().RELEASE || System.getenv().TRAVIS_TAG)
build_number = "RELEASE"
logger.lifecycle "BUILDING VERSION: " + build_number
// Set mod details
version = project.mod_version
group = "org.cyclops.integratedterminals"
archivesBaseName = "IntegratedTerminals-${project.minecraft_version}-neoforge"
base {
archivesName = archivesBaseName
}
// Set Java details
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
compileJava.options.compilerArgs << "-Xmaxerrs" << "9999"
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
// Load secrets
def getSecrets() {
Properties props = new Properties()
if (file('./secrets.properties').exists()) {
props.load(new FileInputStream(file('./secrets.properties')))
}
return props
}
Properties secrets = getSecrets();
sourceSets {
main
test
}
sourceSets.main.resources { srcDir 'src/generated/resources' }
configurations {
shadow.setTransitive(true);
modLib
implementation.extendsFrom modLib
}
test {
testLogging {
exceptionFormat = 'full'
}
}
repositories {
mavenCentral()
mavenLocal()
maven {
name "Cyclops Repo"
url "https://maven.pkg.github.com/CyclopsMC/packages"
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("MAVEN_USERNAME") ?: System.getenv("GITHUB_USER")
password = project.findProperty("gpr.key") ?: System.getenv("MAVEN_KEY") ?: System.getenv("GITHUB_TOKEN")
}
}
flatDir {
name "extra-mods"
dir file(extraModsDir)
}
}
dependencies {
implementation "net.neoforged:neoforge:${project.neoforge_version}"
// Add something like 'cyclopscore_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local CyclopsCore version.
if(secrets.cyclopscore_version_local) {
implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-neoforge:${secrets.cyclopscore_version_local}:deobf"
} else {
implementation "org.cyclops.cyclopscore:cyclopscore-${project.minecraft_version}-neoforge:${project.cyclopscore_version}:deobf"
}
// Add something like 'integrateddynamics_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local Integrated Tunnels Compat version.
if(secrets.integrateddynamics_version_local) {
implementation ("org.cyclops.integrateddynamics:integrateddynamics-${project.minecraft_version}-neoforge:${secrets.integrateddynamics_version_local}:deobf") {
transitive = false
}
} else {
implementation ("org.cyclops.integrateddynamics:integrateddynamics-${project.minecraft_version}-neoforge:${project.integrateddynamics_version}:deobf") {
transitive = false
}
}
// Add something like 'integratedcrafting_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local Integrated Tunnels Compat version.
if(secrets.integratedcrafting_version_local) {
implementation "org.cyclops.integratedcrafting:integratedcrafting-${project.minecraft_version}-neoforge:${secrets.integratedcrafting_version_local}:deobf"
} else {
implementation ("org.cyclops.integratedcrafting:integratedcrafting-${project.minecraft_version}-neoforge:${project.integratedcrafting_version}:deobf") {
transitive = false
}
}
// Add something like 'integratedterminalscompat_version_local=0.1.0-DEV' to your secrets.properties if you want to use a custom local Integrated Tunnels Compat version.
if(secrets.integratedterminalscompat_version_local) {
shadow("org.cyclops.integratedterminalscompat:integratedterminals-compat-${project.minecraft_version}-neoforge:${secrets.integratedterminalscompat_version_local}") {
transitive = false
}
} else {
shadow("org.cyclops.integratedterminalscompat:integratedterminals-compat-${project.minecraft_version}-neoforge:${project.integratedterminalscompat_version}") {
transitive = false
}
}
if(secrets.commoncapabilities_version_local) {
implementation ("org.cyclops.commoncapabilities:commoncapabilities-${project.minecraft_version}-neoforge:${secrets.commoncapabilities_version_local}:deobf") {
transitive = false
}
} else {
implementation ("org.cyclops.commoncapabilities:commoncapabilities-${project.minecraft_version}-neoforge:${project.commoncapabilities_version}:deobf") { // https://dl.bintray.com/cyclopsmc/dev/org/cyclops/commoncapabilities/CommonCapabilities/
transitive = false
}
}
modLib "com.google.re2j:re2j:1.1"
modLib ("io.netty:netty-codec-http:4.1.77.Final") {
transitive = false
}
// Project lombok
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'
testImplementation "junit:junit:4.12"
// Locally sourced extra mods for runtime (i.e. testing)
for (extraModJar in fileTree(dir: extraModsDir, include: '*.jar')) {
def basename = extraModJar.name.substring(0, extraModJar.name.length() - ".jar".length())
def versionSep = basename.lastIndexOf('-')
assert versionSep != -1
def artifactId = basename.substring(0, versionSep)
def version = basename.substring(versionSep + 1)
runtimeOnly fg.deobf("extra-mods:$artifactId:$version")
}
}
minecraft {
accessTransformers {
file('src/main/resources/META-INF/accesstransformer.cfg')
}
}
subsystems {
parchment {
minecraftVersion = "${project.parchment_minecraft_version}"
mappingsVersion = "${project.parchment_version}"
}
}
runs {
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'debug'
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.main
dependencies {
runtime project.configurations.modLib
}
}
client {
systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
}
server {
systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
programArgument '--nogui'
}
gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', "cyclopscore,${mod_id}"
}
data {
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
if (build_number.equals("RELEASE"))
version = "${project.mod_version}"
else
version = "${project.mod_version}-${build_number}"
jar {
archiveClassifier.set('slim')
manifest {
attributes([
"Specification-Title": "${project.name}",
"Specification-Vendor": "rubensworks",
"Specification-Version": "${project.mod_version}",
"Implementation-Title": "${project.name}",
"Implementation-Version": "${project.mod_version}",
"Implementation-Vendor" :"rubensworks",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
task signJar(type: PotentiallySignJar, dependsOn: jar) {
dependsOn(tasks.jar)
onlyIf {
System.getenv().SIGN_KEYSTORE
}
keyStore = System.getenv().SIGN_KEYSTORE
alias = System.getenv().SIGN_ALIAS
storePass = System.getenv().SIGN_STOREPASS
keyPass = System.getenv().SIGN_KEYPASS
input = jar.archivePath
output = jar.archivePath
}
task deobfJar(type: Jar) {
from sourceSets.main.output
archiveClassifier.set('deobf')
manifest {
attributes([
"Specification-Title": "${project.name}",
"Specification-Vendor": "rubensworks",
"Specification-Version": "${project.mod_version}",
"Implementation-Title": "${project.name}",
"Implementation-Version": "${project.mod_version}",
"Implementation-Vendor" :"rubensworks",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
task sourcesJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier.set('sources')
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}
shadowJar {
configurations = [project.configurations.shadow]
archiveClassifier.set(''); // Replace the default JAR
append 'META-INF/neoforge.mods.toml'
relocate 'com.google.re2j', 'vendors.com.google.re2j' // Because Forge blocks all com.google.* class loading...
}
assemble.dependsOn shadowJar
jar {
shadowJar {}
}
artifacts {
archives shadowJar
archives deobfJar
archives sourcesJar
archives javadocJar
}
task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
dependsOn(tasks.jar)
if(secrets.hasProperty("curseforge_key") && secrets.hasProperty("changelog")) {
apiToken = secrets.curseforge_key
} else if(System.getenv().GITHUB_ACTIONS && System.getenv().CURSEFORGE_KEY_SECRET) {
apiToken = System.getenv().CURSEFORGE_KEY_SECRET
} else {
apiToken = "DUMMY"
}
def projectId = "295910" // my project url is http://minecraft.curseforge.com/mc-mods/295910/
def mainFile = upload(projectId, shadowJar)
mainFile.releaseType = 'release'
mainFile.changelogType = "text"
mainFile.changelog = file("resources/changelog/${project.minecraft_version}-${project.version}.txt")
mainFile.addGameVersion(project.minecraft_version)
mainFile.addModLoader("NeoForge")
mainFile.addRequirement('cyclops-core')
mainFile.addRequirement('integrated-dynamics')
mainFile.addRequirement('integrated-tunnels')
mainFile.addOptional('integrated-crafting')
}
modrinth {
if(secrets.modrinth_key) {
token = secrets.modrinth_key
} else if(System.getenv().GITHUB_ACTIONS && System.getenv().MODRINTH_KEY_SECRET) {
token = System.getenv().MODRINTH_KEY_SECRET
} else {
token = "DUMMY"
}
projectId = "HmLJoQ1K"
versionNumber = project.minecraft_version + '-' + project.mod_version
versionType = project.release_type
uploadFile = shadowJar
gameVersions = [ project.minecraft_version ]
changelog = provider { file("resources/changelog/${project.minecraft_version}-${project.version}.txt").getText() }
dependencies { // A special DSL for creating dependencies
required.project "Z9DM0LJ4" // Cyclops Core
required.project "oFXrCkDI" // Common Capabilities
}
}
publishing {
repositories {
if (project.hasProperty("filesmaven_url")) {
logger.info('Publishing to files server')
maven {
url project.filesmaven_url
credentials {
username = project.filesmaven_username
password = project.filesmaven_key
}
}
} else if (System.getenv("MAVEN_URL")) {
logger.info('Publishing to files server')
maven {
url System.getenv("MAVEN_URL")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_KEY")
}
}
} else {
logger.error('No maven repo was set!')
}
}
publications { PublicationContainer publicationContainer ->
publicationContainer.register("maven", MavenPublication) { MavenPublication publication ->
publication.artifacts = [shadowJar, javadocJar, deobfJar, sourcesJar]
publication.artifactId = project.archivesBaseName.toLowerCase() // GH can't handle uppercase...
}
}
}
idea {
module {
downloadSources = true
downloadJavadoc = true
for (String excludeDirName in ["run", "out", "logs", "gradle"]) {
File excludeDir = new File(projectDir, excludeDirName)
excludeDirs.add(excludeDir)
}
}
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
}
spotless {
java {
target 'src/*/java/org/cyclops/**/*.java'
endWithNewline()
trimTrailingWhitespace()
removeUnusedImports()
indentWithSpaces()
}
}
tasks.register('updateGitHooks', Copy) {
from './scripts/pre-commit'
into './.git/hooks'
}
compileJava.dependsOn updateGitHooks
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}