-
Notifications
You must be signed in to change notification settings - Fork 687
/
Copy pathbuild.gradle
405 lines (350 loc) · 11.7 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
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
plugins {
id "net.neoforged.moddev"
id "maven-publish"
id "com.diffplug.spotless"
id 'com.gradleup.shadow'
id "de.undercouch.download"
}
apply plugin: ProjectDefaultsPlugin
base {
archivesName = "appliedenergistics2"
}
neoForge.version = project.neoforge_version
sourceSets {
main {
resources {
srcDir 'src/generated/resources'
}
}
buildtools
}
configurations {
localRuntimeOnly
shaded {
transitive = false
}
buildtoolsImplementation.extendsFrom(compileClasspath)
// Dependencies only used for the guide export, but not shipped
guideExportOnly
configurations.compileClasspath.extendsFrom(guideExportOnly)
configurations.runtimeClasspath.extendsFrom(guideExportOnly)
runtimeClasspath.extendsFrom localRuntimeOnly
}
import appengbuild.*
import com.diffplug.gradle.spotless.JsonExtension
dependencies {
// Used for the guide export
guideExportOnly("org.bytedeco:ffmpeg-platform:${ffmpeg_version}")
implementation(jarJar("appeng:guideme:${guideme_version}"))
// compile against provided APIs
compileOnly "dev.emi:emi-neoforge:${emi_version}:api"
compileOnly "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
compileOnly "mcp.mobius.waila:wthit-api:neo-${project.wthit_version}"
compileOnly "curse.maven:jade-324717:${project.jade_file_id}"
compileOnly "mcjty.theoneprobe:theoneprobe:${project.top_version}"
switch (project.runtime_itemlist_mod) {
case "emi":
localRuntimeOnly "dev.emi:emi-neoforge:${emi_version}"
break
case "rei":
localRuntimeOnly "me.shedaniel:RoughlyEnoughItems-neoforge:${project.rei_version}"
break
}
switch (project.runtime_tooltip_mod) {
case "wthit":
localRuntimeOnly "mcp.mobius.waila:wthit:neo-${project.wthit_version}"
break
case "jade":
localRuntimeOnly "curse.maven:jade-324717:${project.jade_file_id}"
break
case "top":
localRuntimeOnly "mcjty.theoneprobe:theoneprobe:${project.top_version}"
break
}
if (project.runtime_curio == "true") {
localRuntimeOnly("top.theillusivec4.curios:curios-neoforge:${project.curios_version}")
}
// Athena
if (project.runtime_athena == "true") {
localRuntimeOnly("curse.maven:athena-841890:${project.athena_file_id}")
}
// unit test dependencies
testImplementation(platform("org.junit:junit-bom:${project.junit_version}"))
testImplementation(platform("org.assertj:assertj-bom:${project.assertj_version}"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core")
testImplementation("com.google.guava:guava-testlib:21.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.12.0")
testImplementation("net.neoforged:testframework:${project.neoforge_version}")
buildtoolsImplementation 'de.siegmar:fastcsv:2.1.0'
buildtoolsImplementation 'com.google.code.gson:gson:2.8.9'
}
///////////////////
// Version Number
ext.tag = System.getenv('TAG') ?: ""
if (ext.tag) {
if (!ext.tag.startsWith("neoforge/v")) {
throw new GradleException("Tags for the neoforge version should start with neoforge/: ${ext.tag}")
}
project.version = ext.tag.substring("neoforge/v".length())
} else {
// This essentially tries to implement delay expansion of the project version based on a value source to
// still support configuration caching.
project.version = providers.gradleProperty("version").orElse("").flatMap(version -> {
if (!version.isBlank()) {
return providers.provider { version }
}
return providers.of(ProjectVersionSource.class, spec -> {
spec.getParameters().getDefaultBranches().addAll("main", "neoforge/" + project.minecraft_version)
});
}).get()
}
tasks.register("printProjectVersion", PrintProjectVersion.class);
test {
useJUnitPlatform()
// Might not need this anymore...
systemProperty "guideme.ae2.guide.sources", file("guidebook").absolutePath
}
dependencies {
buildtoolsImplementation 'de.siegmar:fastcsv:2.1.0'
buildtoolsImplementation 'com.google.code.gson:gson:2.8.9'
}
/**
* Configures properties common to all run configurations
*/
Map<String, String> commonSystemProperties = [
'appeng.tests' : 'true',
]
neoForge {
mods {
ae2 {
sourceSet sourceSets.main
}
}
runs {
configureEach {
gameDirectory = project.file('run')
systemProperties = commonSystemProperties
// property "mixin.debug.export", "true"
logLevel = org.slf4j.event.Level.INFO
systemProperty('guideme.ae2.guide.sources', file('guidebook').absolutePath)
}
client {
client()
systemProperty('appeng.tests', 'true')
}
gametestWorld {
client()
programArguments = [
'--username', 'AE2Dev', '--quickPlaySingleplayer', 'GametestWorld'
]
systemProperty('appeng.tests', 'true')
}
guide {
client()
systemProperty('guideme.showOnStartup', 'ae2:guide')
}
server {
server()
}
data {
data()
programArguments = [
'--mod', 'ae2',
'--all',
'--output', file('src/generated/resources/').absolutePath,
'--existing', file('src/main/resources').absolutePath
]
}
guideexport {
client()
systemProperty('appeng.runGuideExportAndExit', 'true')
systemProperty('appeng.guideExportFolder', file('build/guide').absolutePath)
}
// Use to run the tests
gametest {
type = 'gameTestServer'
gameDirectory = project.file('build/gametest')
}
}
unitTest {
enable()
testedMod = mods.ae2
}
}
configurations.additionalRuntimeClasspath.extendsFrom configurations.shaded
configurations.additionalRuntimeClasspath.extendsFrom configurations.guideExportOnly
//////////////
// Artifacts
Map<String, String> expansionVariables = [
"project_version": project.version,
'minecraft_version': project.minecraft_version_range,
'neoforge_version': project.neoforge_version_range,
'top_version': project.top_version_range,
'jade_version': project.jade_version_range
]
processResources {
exclude '.cache'
// Ensure the resources get re-evaluate when the version changes
for (var entry : expansionVariables.entrySet()) {
inputs.property(entry.key, entry.value)
}
filesMatching("META-INF/neoforge.mods.toml") {
expand expansionVariables
filter { line ->
line.replace('version="0.0.0"', "version=\"${expansionVariables['project_version']}\"")
}
}
}
jar {
finalizedBy shadowJar
archiveClassifier = "plain"
}
shadowJar {
from sourceSets.main.output.classesDirs
from sourceSets.main.output.resourcesDir
from('guidebook') {
into 'assets/ae2/ae2guide'
}
relocate "io.methvin", "appeng.shaded.methvin"
relocate "org.yaml.snakeyaml", "appeng.shaded.snakeyaml"
configurations = [project.configurations.shaded]
archiveClassifier = null
}
assemble.dependsOn shadowJar
def publicApiIncludePatterns = {
exclude "**/*Internal.*"
exclude "**/*Internal\$*.*"
include "appeng/api/**"
}
javadoc {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath + sourceSets.main.output
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
options.charSet = 'UTF-8'
}
javadoc publicApiIncludePatterns
tasks.register('javadocJar', Jar) {
dependsOn javadoc
archiveClassifier = "javadoc"
from javadoc.destinationDir
}
tasks.register('sourcesJar', Jar) {
archiveClassifier = "sources"
from sourceSets.main.allJava
}
tasks.register('apiJar', Jar) {
archiveClassifier = "api"
// api jar ist just a development aid and serves as both a binary and source jar simultaneously
from sourceSets.main.output
from sourceSets.main.allJava
}
apiJar publicApiIncludePatterns
artifacts {
archives javadocJar
archives sourcesJar
archives apiJar
}
//////////////////
// Maven publish
publishing {
publications {
maven(MavenPublication) {
artifactId = "appliedenergistics2"
version = project.version
artifact shadowJar
artifact sourcesJar
artifact javadocJar
artifact apiJar
}
}
repositories {
maven {
name = "Local"
url = file("build/repo").toURI()
}
}
}
/////////////
// Spotless
spotless {
java {
target 'src/*/java/appeng/**/*.java'
endWithNewline()
indentWithSpaces()
removeUnusedImports()
toggleOffOn()
eclipse().configFile 'codeformat/codeformat.xml'
importOrderFile 'codeformat/ae2.importorder'
// courtesy of diffplug/spotless#240
// https://github.com/diffplug/spotless/issues/240#issuecomment-385206606
custom 'noWildcardImports', {
if (it.contains('*;\n')) {
throw new Error('No wildcard imports allowed')
}
it
}
bumpThisNumberIfACustomStepChanges(1)
}
json {
target 'src/*/resources/**/*.json'
targetExclude 'src/generated/resources/**'
var biomeConfig = it.new JsonExtension.BiomeJson(null)
try {
biomeConfig.downloadDir(new File(rootDir, ".gradle/biome").absolutePath)
} catch (Exception ignored) {
}
addStep(biomeConfig.createStep())
indentWithSpaces(2)
endWithNewline()
}
}
////////////////
// Crowdin
tasks.register('uploadToCrowdin', JavaExec) {
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'Crowdin'
args 'upload_source'
workingDir "."
}
tasks.register('uploadTranslations', JavaExec) {
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'Crowdin'
args 'upload_translations'
workingDir "."
}
tasks.register('downloadFromCrowdin', JavaExec) {
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'Crowdin'
args 'update_translations'
workingDir "."
}
check.dependsOn tasks.register('validateResources', JavaExec) {
group = "verification"
classpath = sourceSets.buildtools.runtimeClasspath
mainClass = 'ValidateResourceIds'
workingDir "."
args "guidebook"
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
}