mirror of
https://github.com/LegacyModdingMC/UniMixins.git
synced 2026-11-21 04:42:13 +00:00
179 lines
5.2 KiB
Groovy
179 lines
5.2 KiB
Groovy
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
|
|
|
archivesBaseName = archivesBaseName.replace("-1.7.10", "-all-1.7.10")
|
|
|
|
// The order of these determines the order embedded core plugins get initialized in
|
|
ext.moduleNames = ["module-mixin", "module-compat", "module-mixingasm", "module-spongemixins", "module-mixinbooterlegacy", "module-gasstation", "module-gtnhmixins", "module-mixinextras"]
|
|
|
|
def getModuleJar(name, source = false) {
|
|
def jarTaskName = name == "module-mixin" ? ":module-mixin:shadow${source ? 'Sources' : ''}JarUnimix" : ":$name:${source ? 'sourcesJar' : 'devJar'}"
|
|
|
|
return tasks.getByPath(jarTaskName).getOutputs().getFiles().getSingleFile()
|
|
}
|
|
|
|
def getModuleJars(source = false) {
|
|
return moduleNames.collect { getModuleJar(it, source) }
|
|
}
|
|
|
|
import java.util.jar.Manifest;
|
|
|
|
def getManifest(file) {
|
|
def man = null
|
|
zipTree(file).matching { include 'META-INF/MANIFEST.MF' }.getSingleFile().withInputStream {
|
|
man = new Manifest(it).mainAttributes
|
|
}
|
|
return man
|
|
}
|
|
|
|
task createMergedMcmodInfo() {
|
|
outputs.file("build/tmp/mcmod.info")
|
|
outputs.upToDateWhen { false }
|
|
doLast {
|
|
def mergedJson = []
|
|
getModuleJars().each {
|
|
def json = new groovy.json.JsonSlurper().parseText(zipTree(it).matching { include 'mcmod.info' }.getSingleFile().text)
|
|
json[0]["parent"] = "unimixins"
|
|
mergedJson += json
|
|
}
|
|
|
|
def desc = mergedJson.collect{ it.name.split(": ")[1]}.join("; ")
|
|
mergedJson = [
|
|
[
|
|
modid: "unimixins",
|
|
name: "UniMixins",
|
|
description: "UniMixins composite jar consisting of the following modules:\n" + desc,
|
|
version: version,
|
|
mcversion: "1.7.10",
|
|
url: project_url,
|
|
authorList: ["makamys"],
|
|
]
|
|
] + mergedJson
|
|
|
|
file("build/tmp/mcmod.info").text = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(mergedJson))
|
|
return file("build/tmp/mcmod.info")
|
|
}
|
|
|
|
moduleNames.each { dependsOn tasks.getByPath(":$it:build") }
|
|
}
|
|
|
|
task createEmbeddedCorePluginsFile() {
|
|
def path = "build/tmp/unimixins-all.EmbeddedFMLCorePlugins.txt"
|
|
outputs.file(path)
|
|
outputs.upToDateWhen { false }
|
|
doLast {
|
|
file(path).text = getModuleJars().findResults { getManifest(it).getValue("FMLCorePlugin") }.join(' ')
|
|
return file(path)
|
|
}
|
|
|
|
moduleNames.each { dependsOn tasks.getByPath(":$it:build") }
|
|
}
|
|
|
|
task createMergedAnnotationProcessorConfig() {
|
|
def path = "build/tmp/javax.annotation.processing.Processor"
|
|
outputs.file(path)
|
|
outputs.upToDateWhen { false }
|
|
doLast {
|
|
// MixinExtras's APs have to be registered before Mixin's,
|
|
// so we manually merge the APs to ensure this is the case.
|
|
file(path).text = """com.llamalad7.mixinextras.MixinExtrasAP
|
|
io.github.tox1cozz.mixinextras.MixinExtrasAnnotationProcessor
|
|
com.gtnewhorizon.mixinextras.MixinExtrasAP
|
|
org.spongepowered.tools.obfuscation.MixinObfuscationProcessorInjection
|
|
org.spongepowered.tools.obfuscation.MixinObfuscationProcessorTargets
|
|
"""
|
|
|
|
return file(path)
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
shadow(project(":module-common")) {
|
|
transitive = false
|
|
}
|
|
}
|
|
|
|
shadowJar {
|
|
dependsOn tasks.createMergedMcmodInfo
|
|
dependsOn tasks.createEmbeddedCorePluginsFile
|
|
dependsOn tasks.createMergedAnnotationProcessorConfig
|
|
|
|
configurations = [project.configurations.shadow]
|
|
classifier = ''
|
|
relocate 'io.github.legacymoddingmc.unimixins.common', 'io.github.legacymoddingmc.unimixins.all.repackage.common'
|
|
|
|
moduleNames.each {
|
|
def name = it
|
|
def j = getModuleJar(it)
|
|
into ""
|
|
from(zipTree(j)){
|
|
exclude 'mcmod.info'
|
|
exclude 'META-INF/MANIFEST.MF'
|
|
exclude 'CREDITS', 'LICENSE*', 'README*'
|
|
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
|
into("")
|
|
}
|
|
from(zipTree(j)){
|
|
include 'CREDITS', 'LICENSE*', 'README*'
|
|
into("META-INF/licenses/$name")
|
|
}
|
|
}
|
|
|
|
from tasks.createMergedMcmodInfo.getOutputs().getFiles().getSingleFile()
|
|
from(tasks.createEmbeddedCorePluginsFile.getOutputs().getFiles().getSingleFile()) {
|
|
into 'META-INF'
|
|
}
|
|
from(tasks.createMergedAnnotationProcessorConfig.getOutputs().getFiles().getSingleFile()) {
|
|
into 'META-INF/services'
|
|
}
|
|
|
|
manifest {
|
|
attributes (
|
|
'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
|
'FMLCorePluginContainsFMLMod': true,
|
|
'ForceLoadAsMod': true,
|
|
'FMLCorePlugin': 'io.github.legacymoddingmc.unimixins.all.AllCore',
|
|
'MixinConfigs': 'mixins.gtnhmixins.json,mixins.gasstation.json,mixins.gtnhmixins.json,mixingasm.mixin.json',
|
|
'Premain-Class': 'org.spongepowered.tools.agent.MixinAgent',
|
|
'Agent-Class': 'org.spongepowered.tools.agent.MixinAgent',
|
|
'Can-Redefine-Classes': true,
|
|
'Can-Retransform-Classes': true,
|
|
)
|
|
}
|
|
|
|
doFirst {
|
|
manifest.attributes (
|
|
'Implementation-Version': getManifest(getModuleJar("module-mixin")).getValue("Implementation-Version")
|
|
)
|
|
}
|
|
}
|
|
|
|
jar {
|
|
enabled = false
|
|
dependsOn shadowJar
|
|
}
|
|
|
|
task sourcesJar(type: ShadowJar) {
|
|
dependsOn shadowJar
|
|
|
|
classifier = 'sources'
|
|
|
|
moduleNames.each {
|
|
def j = getModuleJar(it, true)
|
|
from(zipTree(j)){
|
|
exclude 'mcmod.info'
|
|
exclude 'META-INF/MANIFEST.MF'
|
|
exclude 'CREDITS', 'LICENSE*', 'README*'
|
|
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
|
}
|
|
}
|
|
|
|
from(zipTree(tasks.shadowJar.getOutputs().getFiles().getSingleFile())) {
|
|
include "CREDITS"
|
|
include "META-INF/licenses/**"
|
|
}
|
|
}
|
|
|
|
clean {
|
|
moduleNames.each { dependsOn tasks.getByPath(":$it:clean") }
|
|
}
|