This repository has been archived by the owner on Dec 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
311 lines (265 loc) · 10.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
import com.gtnewhorizons.retrofuturagradle.mcp.ReobfuscatedJar
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
name 'forge'
url 'https://maven.minecraftforge.net'
}
maven {
// GTNH RetroFuturaGradle and ASM Fork
name "GTNH Maven"
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
}
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
}
plugins {
id 'java-library'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version ,unused, available for addon.gradle
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'com.palantir.git-version' version '0.13.0' apply false // 0.13.0 is the last jvm8 supporting version
id 'de.undercouch.download' version '5.3.0'
id 'com.gtnewhorizons.retrofuturagradle' version '1.1.6'
}
if (project.file('.git/HEAD').isFile()) {
apply plugin: 'com.palantir.git-version'
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
apply plugin: "com.github.johnrengelman.shadow"
def projectJavaVersion = JavaLanguageVersion.of(8)
java {
toolchain {
languageVersion.set(projectJavaVersion)
vendor.set(JvmVendorSpec.ADOPTIUM)
}
withSourcesJar()
}
version = System.getenv("RELEASE_VERSION") ?: gitVersion()
group = "com.gtnewhorizon" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "gtnhmixins"
configurations {
repackMixin
repackMixinSources
repackMixinProcessor
annotationProcessor
create("runtimeOnlyNonPublishable") {
description = "Runtime only dependencies that are not published alongside the jar"
canBeConsumed = false
canBeResolved = false
}
sources {
transitive = false
}
}
subprojects {
apply plugin: 'java'
}
ext {
mixinVersion = '0.8.5-GTNH-2'
mixinExtrasVersion = '0.1.1'
asmVersion = '9.4'
mixinSrg = new File(buildDir, "mixins/mixins.gtnhmixins.srg")
mixinRefMap = new File(buildDir, "mixins/mixins.gtnhmixins.refmap.json")
}
minecraft {
tagReplacementFiles.add("GTNHMixins.java")
injectedTags.put("GRADLETOKEN_VERSION", project.version)
}
repositories {
mavenLocal()
maven {
// GTNH ForgeGradle Fork
name = "GTNH Maven"
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
allowInsecureProtocol = true
}
maven {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
}
maven {
// Fernflower
name = "Fabric Maven"
url = "https://maven.fabricmc.net/"
}
flatDir {
dirs 'dependencies'
}
}
dependencies {
repackMixin("org.spongepowered:mixin:$mixinVersion")
repackMixin("com.github.LlamaLad7:MixinExtras:$mixinExtrasVersion")
repackMixin("org.ow2.asm:asm-tree:$asmVersion")
repackMixin("org.ow2.asm:asm-commons:$asmVersion")
repackMixin("org.ow2.asm:asm-util:$asmVersion")
repackMixin("com.google.guava:guava:21.0")
repackMixinSources("org.spongepowered:mixin:$mixinVersion:sources")
repackMixinSources("com.github.LlamaLad7:MixinExtras:$mixinExtrasVersion:sources")
repackMixinSources("org.ow2.asm:asm-tree:$asmVersion:sources")
repackMixinSources("org.ow2.asm:asm-commons:$asmVersion:sources")
repackMixinSources("org.ow2.asm:asm-util:$asmVersion:sources")
repackMixinSources("com.google.guava:guava:21.0:sources")
runtimeOnlyNonPublishable('org.jetbrains:intellij-fernflower:1.2.1.16')
repackMixinProcessor("com.github.LlamaLad7:MixinExtras:$mixinExtrasVersion")
repackMixinProcessor("org.spongepowered:mixin:$mixinVersion:processor")
}
tasks.named("reobfJar", ReobfuscatedJar).configure {
extraSrgFiles.from(mixinSrg)
}
task copySrgs(type: Copy, dependsOn: tasks.generateForgeSrgMappings) {
from project.mcpTasks.forgeSrgLocation
include '**/*.srg'
into 'build/srgs'
}
// Execute for generate mixin repack jar
task repackMixinJar(type: ShadowJar) {
destinationDirectory.set(layout.projectDirectory.dir('dependencies'))
archiveFileName.set("mixin-$mixinVersion-repack.jar")
configurations = [project.configurations.repackMixin]
mergeServiceFiles()
exclude 'META-INF/MANIFEST.MF', 'META-INF/maven/**', 'META-INF/*.RSA', 'META-INF/*.SF'
exclude '**/module-info.class'
relocate 'org.objectweb.asm', 'org.spongepowered.libraries.org.objectweb.asm'
relocate 'com.llamalad7.mixinextras', 'com.gtnewhorizon.mixinextras'
relocate 'com.google.common', 'org.spongepowered.libraries.com.google.common'
relocate 'com.google.thirdparty.publicsuffix', 'org.spongepowered.libraries.com.google.thirdparty.publicsuffix'
}
// Execute for generate mixin sources repack jar
task repackMixinSourcesJar(type: ShadowJar) {
destinationDirectory.set(layout.projectDirectory.dir('dependencies'))
archiveFileName.set("mixin-$mixinVersion-sources-repack.jar")
configurations = [project.configurations.repackMixinSources]
mergeServiceFiles()
exclude 'META-INF/MANIFEST.MF', 'META-INF/maven/**', 'META-INF/*.RSA', 'META-INF/*.SF'
exclude '**/module-info.class'
relocate 'org.objectweb.asm', 'org.spongepowered.libraries.org.objectweb.asm'
relocate 'com.llamalad7.mixinextras', 'com.gtnewhorizon.mixinextras'
relocate 'com.google.common', 'org.spongepowered.libraries.com.google.common'
relocate 'com.google.thirdparty.publicsuffix', 'org.spongepowered.libraries.com.google.thirdparty.publicsuffix'
}
// Execute for generate mixin annotation processor repack jar
task repackMixinProcessorJar(type: ShadowJar) {
destinationDirectory.set(layout.projectDirectory.dir('dependencies'))
archiveFileName.set("mixin-$mixinVersion-processor-repack.jar")
configurations = [project.configurations.repackMixinProcessor]
mergeServiceFiles()
exclude 'META-INF/MANIFEST.MF', 'META-INF/maven/**', 'META-INF/*.RSA', 'META-INF/*.SF'
exclude '**/module-info.class'
relocate 'org.objectweb.asm', 'org.spongepowered.libraries.org.objectweb.asm'
relocate 'com.llamalad7.mixinextras', 'com.gtnewhorizon.mixinextras'
relocate 'com.google.common', 'org.spongepowered.libraries.com.google.common'
relocate 'com.google.gson', 'org.spongepowered.libraries.com.google.gson'
relocate 'org.apache.logging.log4j', 'org.spongepowered.libraries.org.apache.logging.log4j'
relocate 'com.google.thirdparty.publicsuffix', 'org.spongepowered.libraries.com.google.thirdparty.publicsuffix'
}
dependencies {
implementation(files(tasks.named("repackMixinJar", Jar)))
annotationProcessor(files(tasks.named("repackMixinProcessorJar", Jar)))
}
compileJava {
dependsOn copySrgs
options.compilerArgs += [
'-Xlint:-processing',
"-AoutSrgFile=${mixinSrg.canonicalPath}",
"-AoutRefMapFile=${mixinRefMap.canonicalPath}",
"-AreobfSrgFile=${file('build/srgs/mcp-srg.srg').canonicalPath}"
]
options.encoding = 'UTF-8'
}
jar {
manifest {
attributes([
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
'FMLCorePluginContainsFMLMod': 'true',
"FMLCorePlugin" : "com.gtnewhorizon.gtnhmixins.core.GTNHMixinsCore",
"MixinConfigs" : "mixins.gtnhmixins.json",
"TweakOrder" : -2147483648,
"ForceLoadAsMod" : true,
"Premain-Class" : "org.spongepowered.tools.agent.MixinAgent",
"Agent-Class" : "org.spongepowered.tools.agent.MixinAgent",
"Can-Redefine-Classes" : true,
"Can-Retransform-Classes" : true,
"Implementation-Title" : "${modId}",
"Implementation-Version" : "${mixinVersion}",
"Implementation-Vendor" : "GT New Horizons",
])
}
from(zipTree(tasks.named("repackMixinJar", Jar).flatMap {it.archiveFile})) {
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.MF"
exclude "META-INF/services/*.Processor"
// Replaced by local classes
exclude "org/spongepowered/asm/bridge/**"
}
}
task annotationProcessorJar(type: Jar, dependsOn: classes) {
archiveClassifier.set('processor')
from(sourceSets.main.output) {
include 'META-INF/services/javax.annotation.processing.Processor'
}
from(zipTree(tasks.named("repackMixinProcessorJar", Jar).flatMap {it.archiveFile})) {
exclude 'LICENSE.txt'
}
}
tasks.named("sourcesJar", Jar).configure {
from(zipTree(tasks.named("repackMixinSourcesJar", Jar).flatMap {it.archiveFile})) {
exclude 'LICENSE.txt'
exclude 'META-INF/services/*.Processor'
// Replaced by custom classes
exclude 'org/spongepowered/asm/bridge/**'
}
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "modVersion", project.version
inputs.property "minecraftVersion", minecraft.mcVersion
inputs.property "modId", project.modId
// replace stuff in mcmod.info, nothing else. replaces ${key} with value in text
filesMatching("mcmod.info") {
expand "minecraftVersion": minecraft.mcVersion.get(),
"modVersion": project.version,
"modId": project.modId
}
}
artifacts {
archives annotationProcessorJar
archives sourcesJar
}
tasks.named("shadowJar", ShadowJar).configure {
enabled = false
}
AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.components.findByName("java")
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
skip()
}
publishing {
publications {
maven(MavenPublication) {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
from components.java
artifact(annotationProcessorJar) {
builtBy annotationProcessorJar
}
}
}
repositories {
maven {
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
allowInsecureProtocol = true
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}