generated from CleanroomMC/TemplateDevEnv
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
360 lines (320 loc) · 11.5 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
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
import org.jetbrains.gradle.ext.Gradle
plugins {
id("java")
id("java-library")
id("maven-publish")
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
id("eclipse")
id("com.gtnewhorizons.retrofuturagradle") version "1.3.27"
id("com.matthewprenger.cursegradle") version "1.4.0"
id('io.github.srdjan-v.local-git-dependency') version '0.5.2'
}
def currentBranch = ("git rev-parse --abbrev-ref HEAD").execute().inputStream.readLines().get(0)
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 {
languageVersion.set(JavaLanguageVersion.of(8))
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
vendor.set(JvmVendorSpec.AZUL)
}
// Generate sources and javadocs jars when building and publishing
withSourcesJar()
//withJavadocJar()
}
minecraft {
mcVersion = '1.12.2'
def args = ["-ea:${project.group}"]
if (project.use_coremod.toBoolean()) {
args << '-Dfml.coreMods.load=' + coremod_plugin_class_name
}
if (project.use_mixins.toBoolean()) {
args << '-Dmixin.hotSwap=true'
args << '-Dmixin.checks.interfaces=true'
args << '-Dmixin.debug.export=true'
}
extraRunJvmArguments.addAll(args)
useDependencyAccessTransformers = true
injectedTags.put("VERSION", project.version)
injectedTags.put("TWEAKED_LIB_VERSION", tweaked_lib_version)
}
// Generate a my.project.Tags class with the version number as a field
tasks.injectTags.configure {
outputClassName.set("${project.group}.${project.archives_base_name}.Tags")
}
repositories {
mavenCentral()
maven {
url = 'https://maven.cleanroommc.com'
}
maven {
url = 'https://repo.spongepowered.org/maven'
}
maven {
url "https://cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven { // TOP
name 'tterrag maven'
url "https://maven.tterrag.com/"
}
maven {
name 'jared maven'
url 'https://maven.blamejared.com/'
content {
includeGroup "CraftTweaker2"
}
}
maven {
// location of the maven that hosts JEI files
name = "Progwml6 maven"
url = "https://dvs1.progwml6.com/files/maven/"
}
mavenLocal()
}
configurations {
embed
implementation.extendsFrom(embed)
}
dependencies {
compileOnly "org.jetbrains:annotations:24.0.1"
//Hwyla
implementation "curse.maven:hwyla-253449:2568751-sources-2568752-api-2568753"
//compileOnly "curse.maven:hwyla-253449:2568751-sources-2568752-api-2568753"
//implementation "curse.maven:top-245211:2667280"
implementation "mcjty.theoneprobe:TheOneProbe-1.12:1.12-1.4.28-17"
implementation 'CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.679'
implementation ("com.cleanroommc:groovyscript:${project.groovy_script_version}") {
exclude group: 'mezz.jei', module: 'jei_1.12.2'
exclude group: 'curse.maven', module: 'top-245211'
exclude group: 'zone.rong', module: 'mixinbooter'
exclude group: 'codechicken', module:'codechickenlib'
}
implementation rfg.deobf('curse.maven:ImmersiveEngineering-231951:2974106')
implementation rfg.deobf('curse.maven:ImmersivePetroleum-268250:3382321')
//AdvancedRocketry
implementation rfg.deobf('curse.maven:AdvancedRocketry-236542:3801020')
implementation rfg.deobf('curse.maven:Libvulpes-236541:3801015')
//compileOnly rfg.deobf('mezz.jei:jei_1.12.2:4.16.1.302:api')
//runtimeOnly rfg.deobf('mezz.jei:jei_1.12.2:4.16.1.302')
//implementation fg.deobf('curse.maven:had-enough-items-557549:3862733')
//enables java 17 features on java 8
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
annotationProcessor 'net.java.dev.jna:jna-platform:5.13.0'
compileOnly 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0'
if (project.use_assetmover.toBoolean()) {
implementation 'com.cleanroommc:assetmover:2.0'
}
if (project.use_mixins.toBoolean()) {
annotationProcessor 'org.ow2.asm:asm-debug-all:5.2'
annotationProcessor 'com.google.guava:guava:32.1.2-jre'
annotationProcessor 'com.google.code.gson:gson:2.8.9'
String mixinBooter = modUtils.enableMixins('zone.rong:mixinbooter:8.9')
api (mixinBooter) {transitive = false}
annotationProcessor (mixinBooter) {transitive = false}
}
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
}
localGitDependency {
add('https://github.com/Srdjan-V/TweakedLib.git', {
buildLauncher {
startup {
mainTasks "setupCIWorkspace"
}
}
configuration("runtimeOnly")
enableIdeSupport true
mapSourceSets({
map "main", "main"
})
if (currentBranch == "master") {
keepGitUpdated true
tag 'v' + project.tweaked_lib_version
} else {
keepGitUpdated false
branch 'develop'
}
})
add('https://github.com/CleanroomMC/HadEnoughItems.git', {
buildLauncher {
setExecutable(javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
})
startup {
mainTasks "setupCIWorkspace"
}
}
tag project.hei_version
configuration({
configuration("compileOnly")
include("mezz.jei:HadEnoughItems_1.12.2:${project.hei_version}-api")
}, {
configuration("runtimeOnly")
include("mezz.jei:HadEnoughItems_1.12.2:${project.hei_version}")
})
})
}
def mixinConfigRefMap = 'mixins.' + project.archives_base_name + '.refmap.json'
def mixinTmpDir = buildDir.path + File.separator + 'tmp' + File.separator + 'mixins'
def refMap = "${mixinTmpDir}" + File.separator + mixinConfigRefMap
def mixinSrg = "${mixinTmpDir}" + File.separator + "mixins.srg"
if (project.use_mixins.toBoolean()) {
tasks.named("reobfJar", ReobfuscatedJar).configure {
extraSrgFiles.from(mixinSrg)
}
tasks.named("compileJava", JavaCompile).configure {
doFirst {
new File(mixinTmpDir).mkdirs()
}
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobfJar.srg.get().asFile}",
"-AoutSrgFile=${mixinSrg}",
"-AoutRefMapFile=${refMap}",
]
}
}
if (project.use_access_transformer.toBoolean()) {
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)
}
}
}
jar {
manifest {
def attribute_map = [:]
if (project.use_coremod.toBoolean()) {
attribute_map['FMLCorePlugin'] = project.coremod_plugin_class_name
if (project.include_mod.toBoolean()) {
attribute_map['FMLCorePluginContainsFMLMod'] = true
attribute_map['ForceLoadAsMod'] = project.gradle.startParameter.taskNames[0] == "build"
}
}
if (project.use_access_transformer.toBoolean()) {
attribute_map['FMLAT'] = project.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) } })
}
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
)
}
if (project.use_access_transformer.toBoolean()) {
rename '(.+_at.cfg)', 'META-INF/$1' // Access Transformers
}
if (project.use_mixins.toBoolean()) {
// Embed mixin refmap
from refMap
dependsOn("compileJava")
}
}
tasks.register('updateGitVersionTag') {
doLast {
def versionTagArray = new ArrayList<Integer>()
for (versionString in project.version.toString().trim().split("\\.")) {
versionTagArray.add(Integer.valueOf(versionString))
}
def gitVersionTagArray = new ArrayList<Integer>()
def gitStringTag = ("git describe --tags --abbrev=0").execute().inputStream.readLines().get(0)
for (versionString in gitStringTag.substring(1, gitStringTag.length()).trim().split("\\.")) {
gitVersionTagArray.add(Integer.valueOf(versionString))
}
def invalid = true
def smallestSizeArray = versionTagArray.size() > gitVersionTagArray.size() ? gitVersionTagArray.size() : versionTagArray.size()
for (i in 0..<smallestSizeArray) {
if (versionTagArray.get(i) > gitVersionTagArray.get(i)) {
invalid = false
break
}
}
if (!invalid && versionTagArray.size() > gitVersionTagArray.size()) {
invalid = false
}
if (invalid) {
project.logger.error("Current project version is the same or lower then the latest tag")
return
}
project.logger.lifecycle('Pushing tag {}', project.version)
("git tag v${project.version}").execute()
("git push --tags").execute()
}
}
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(' ')
]
}
}
}
}
}
tasks.named("processIdeaSettings").configure {
dependsOn("injectTags")
}
afterEvaluate {
tasks.withType(JavaCompile.class).configureEach {
options.encoding = "UTF-8"
sourceCompatibility = 17 // for the IDE support
options.release = 8
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
configure([tasks.javadoc]) {
javadocTool.set(javaToolchains.javadocToolFor {
languageVersion = JavaLanguageVersion.of(17)
})
}
tasks.named('test') {
useJUnitPlatform()
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourcesJar
}
}
}