forked from GregTechCEu/Gregification
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
343 lines (296 loc) · 11.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
//file:noinspection DependencyNotationArgument
// TODO remove when fixed in RFG ^
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.gradle.ext.Gradle
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'eclipse'
id 'org.jetbrains.gradle.plugin.idea-ext' version "$idea_ext_version"
id 'com.gtnewhorizons.retrofuturagradle' version "$rfg_version"
id 'net.darkhax.curseforgegradle' version "$curseforge_gradle_version" apply false
id 'com.modrinth.minotaur' version "$minotaur_version" apply false
}
version = project.mod_version
group = project.maven_group
archivesBaseName = project.archives_base_name
// Set the toolchain version to decouple the Java we run Gradle with from the Java used to compile and run the mod
java {
toolchain {
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
vendor.set(JvmVendorSpec.AZUL)
languageVersion.set(JavaLanguageVersion.of(project.java_version))
}
// Generate sources when building and publishing
withSourcesJar()
// javadoc jar throws errors on incomplete docs
// docs are also contained in the sources jar, so omit the javadoc-only jar
}
tasks.withType(JavaCompile).configureEach {
options.encoding 'UTF-8'
}
configurations {
embed
implementation.extendsFrom(embed)
}
minecraft {
mcVersion = project.mc_version
def args = [
"-ea:${project.group}",
"-Dfml.coreMods.load=${coremod_plugin_class_name}"
]
extraRunJvmArguments.addAll(args)
useDependencyAccessTransformers = true
injectedTags.put('VERSION', project.version)
}
// Generate the InternalTags class with the version number as a field
tasks.injectTags.configure {
outputClassName.set("${project.group}.GFInternalTags")
}
repositories {
maven {
// MixinBooter
name 'Cleanroom Maven'
url 'https://maven.cleanroommc.com'
}
maven {
// CraftTweaker and JEI Backup
name 'BlameJared Maven'
url 'https://maven.blamejared.com'
}
maven {
// TOP, CTM, GRS, AE2
name 'Curse Maven'
url 'https://www.cursemaven.com'
content {
includeGroup 'curse.maven'
}
}
maven {
// Mixin
name 'Sponge Maven'
url 'https://repo.spongepowered.org/maven'
}
mavenLocal() // Must be last for caching to work
}
dependencies {
// Hard Dependencies
// the CCL deobf jar uses very old MCP mappings, making it error at runtime in runClient/runServer
// therefore we manually deobf the regular jar
implementation rfg.deobf("curse.maven:codechicken-lib-1-8-${ccl_pid}:${ccl_fid}")
// manually deobf the jar to prevent extra configuration for handling obf/deobf separation
implementation rfg.deobf("curse.maven:gregtech-ce-unofficial-${gt_pid}:${gt_fid}-sources-${gt_sources_fid}")
implementation "zone.rong:mixinbooter:${mixinbooter_version}"
// Soft Dependencies
implementation "mezz.jei:jei_1.12.2:${project.jei_version}"
implementation "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-${project.crt_version}"
implementation rfg.deobf("curse.maven:top-${top_pid}:${top_fid}")
implementation rfg.deobf("curse.maven:ctm-${ctm_pid}:${ctm_fid}")
implementation files("libs/groovyscript-0.4.0.jar")
// Compat Mods
implementation rfg.deobf("curse.maven:forestry-59751:2918418")
implementation rfg.deobf("curse.maven:tinkers-construct-74072:2902483")
implementation rfg.deobf("curse.maven:mantle-74924:2713386")
implementation rfg.deobf("curse.maven:shadowfacts-forgelin-248453:2785465")
implementation rfg.deobf("curse.maven:ex-nihilo-creatio-274456:2817545")
implementation rfg.deobf("curse.maven:opencomputers-223008:2828357")
implementation rfg.deobf("curse.maven:tfcraft-302973:3268988")
implementation rfg.deobf("curse.maven:ae2-extended-life-${project.ae2_pid}:${project.ae2_fid}")
implementation rfg.deobf("curse.maven:gregtech-food-option-${project.gtfo_id}:${project.gtfo_version}")
// May get some form of compatibility in the future
//implementation rfg.deobf("curse.maven:mcjtylib-233105:2745846")
//implementation rfg.deobf("curse.maven:xnet-260912:2745852")
// Addons and other mods
// Enable for testing as needed
//implementation rfg.deobf("curse.maven:binnies-mods-223525:2916129")
//implementation rfg.deobf("curse.maven:magic-bees-65764:2566282")
//implementation rfg.deobf("curse.maven:gendustry-70492:2516215")
//implementation rfg.deobf("curse.maven:bdlib-70496:2518031")
//implementation rfg.deobf("curse.maven:career-bees-281791:2534481")
//implementation rfg.deobf("curse.maven:retrobees-300139:2934369")
//implementation rfg.deobf("curse.maven:the-twilight-forest-227639:3051450")
//implementation rfg.deobf("curse.maven:thaumcraft-223628:2629023")
//implementation rfg.deobf("curse.maven:baubles-227083:2518667")
//implementation rfg.deobf("curse.maven:biomes-o-plenty-220318:2715506")
//implementation rfg.deobf("curse.maven:extra-utilities-225561:2678374")
// Mixin dependencies
api("org.spongepowered:mixin:${mixin_version}") {
transitive = false
}
annotationProcessor("org.spongepowered:mixin:${mixin_version}") {
transitive = false
}
annotationProcessor "org.ow2.asm:asm-debug-all:${asm_debug_version}"
annotationProcessor "com.google.guava:guava:${guava_version}-jre"
annotationProcessor "com.google.code.gson:gson:${gson_version}"
}
//noinspection ConfigurationAvoidance
for (File at : sourceSets.getByName('main').resources.files) {
if (at.name.toLowerCase().endsWith('_at.cfg')) {
tasks.deobfuscateMergedJarToSrg.accessTransformerFiles.from at
tasks.srgifyBinpatchedJar.accessTransformerFiles.from at
}
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
// replace stuff in mcmod.info, nothing else
filesMatching(['mcmod.info', 'pack.mcmeta']) { fcd ->
// replace version and mcversion
fcd.expand(
'version': project.version,
'mcversion': project.minecraft.version
)
}
rename '(.+_at.cfg)', 'META-INF/$1' // Access Transformers
}
jar {
manifest {
def attribute_map = [:]
attribute_map['FMLCorePlugin'] = coremod_plugin_class_name
attribute_map['FMLCorePluginContainsFMLMod'] = true
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == 'build'
attribute_map['TweakClass'] = 'org.spongepowered.asm.launch.MixinTweaker'
attribute_map['FMLAT'] = archives_base_name + '_at.cfg'
attributes(attribute_map)
}
// Add all embedded dependencies into the jar
from provider {
configurations.embed.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
test {
testLogging {
events TestLogEvent.STARTED, TestLogEvent.PASSED, TestLogEvent.FAILED
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showStackTraces true
showCauses true
showStandardStreams true
}
useJUnitPlatform()
}
idea {
module {
inheritOutputDirs true
downloadJavadoc true
downloadSources true
}
project {
settings {
runConfigurations {
'1. Run Client'(Gradle) {
taskNames = ['runClient']
}
'2. Run Server'(Gradle) {
taskNames = ['runServer']
}
'3. Run Obfuscated Client'(Gradle) {
taskNames = ['runObfClient']
}
'4. Run Obfuscated Server'(Gradle) {
taskNames = ['runObfServer']
}
}
compiler.javac {
afterEvaluate {
javacAdditionalOptions = '-encoding utf8'
moduleJavacAdditionalOptions = [
(project.name + '.main'): tasks.compileJava.options.compilerArgs.collect {
'"' + it + '"'
}.join(' ')
]
}
}
}
}
}
// Create API library jar
tasks.register('apiJar', Jar) {
archiveClassifier.set 'api'
from(sourceSets.main.java) {
include 'gregicality.multiblocks/api/**'
}
from(sourceSets.main.output) {
include 'gregicality.multiblocks/api/**'
}
}
sourceSets {
main {
ext.refMap = 'mixins.' + archives_base_name + '.refmap.json'
java {
srcDirs = ['src/main/java', 'src/api/java']
}
}
test {
java {
compileClasspath += patchedMc.output + mcLauncher.output
runtimeClasspath += patchedMc.output + mcLauncher.output
}
}
}
tasks.named('processIdeaSettings').configure {
dependsOn('injectTags')
}
// Deployment, for when this is ready for release
/*final boolean is_ci_env = providers.environmentVariable('CI').getOrElse('false').toBoolean()
final boolean deployment_debug = providers.environmentVariable('DEPLOYMENT_DEBUG').getOrElse("$deployment_debug").toBoolean()
if (is_ci_env || deployment_debug) {
artifacts {
archives jar
archives apiJar
archives sourcesJar
}
}
def final cf_api_key = providers.environmentVariable('CURSEFORGE_API_KEY')
if (cf_api_key.isPresent() || deployment_debug) {
apply plugin: 'net.darkhax.curseforgegradle'
//noinspection UnnecessaryQualifiedReference
tasks.register('curseforge', net.darkhax.curseforgegradle.TaskPublishCurseForge) {
apiToken = cf_api_key.get()
def final projectId = providers.environmentVariable('CURSEFORGE_PROJECT_ID').get()
def mainFile = upload(projectId, reobfJar)
mainFile.releaseType = providers.environmentVariable('RELEASE_TYPE').get()
mainFile.changelog = providers.environmentVariable('CHANGELOG_LOCATION').get()
mainFile.changelogType = 'markdown'
mainFile.addRequirement 'codechicken-lib-1-8'
mainFile.addRequirement 'gregtech-ce-unofficial'
mainFile.addIncompatibility 'gregtechce'
mainFile.addModLoader 'Forge'
mainFile.addJavaVersion "Java ${java_version}"
mainFile.addGameVersion "$mc_version"
def sourcesFile = mainFile.withAdditionalFile(sourcesJar)
sourcesFile.changelog = providers.environmentVariable('CHANGELOG_LOCATION').get()
def devFile = mainFile.withAdditionalFile(jar)
devFile.changelog = providers.environmentVariable('CHANGELOG_LOCATION').get()
disableVersionDetection()
}
tasks.curseforge.dependsOn(build)
}
def final modrinth_api_key = providers.environmentVariable('MODRINTH_API_KEY')
if (modrinth_api_key.isPresent() || deployment_debug) {
apply plugin: 'com.modrinth.minotaur'
modrinth {
token = modrinth_api_key.get()
projectId = providers.environmentVariable("MODRINTH_PROJECT_ID").get()
changelog = providers.environmentVariable("CHANGELOG_LOCATION").get()
versionType = providers.environmentVariable("RELEASE_TYPE").get()
versionNumber = "$version".split('-')[0] // strip out the EXTRA field, if present
gameVersions = ["$mc_version"]
loaders = ["forge"]
def main_artifact = "${archivesBaseName}-${version}.jar"
uploadFile = file("build/libs/${main_artifact}")
file('build/libs/').eachFile { file ->
if (file.name.endsWith('.jar') && file.name != main_artifact) {
additionalFiles.add file
}
}
debugMode = deployment_debug
}
tasks.modrinth.dependsOn(build)
} */