mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-12 04:57:33 +00:00
148 lines
4.8 KiB
Groovy
148 lines
4.8 KiB
Groovy
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
jcenter()
|
|
maven {
|
|
name = "forge"
|
|
url = "http://files.minecraftforge.net/maven"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
|
}
|
|
}
|
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
|
|
ext.configFile = file "build.properties"
|
|
configFile.withReader {
|
|
// read config. it shall from now on be referenced as simply config or as project.config
|
|
def prop = new Properties()
|
|
prop.load(it)
|
|
project.ext.config = new ConfigSlurper().parse prop
|
|
}
|
|
ext.release = (rootProject.ext.config.snapshot == "" || rootProject.ext.config.snapshot == "0" || rootProject.ext.config.snapshot == 0)
|
|
//Example: 14.4a-SNAPSHOT-20160820
|
|
version = rootProject.ext.config.version + rootProject.ext.config.dev_version +
|
|
(ext.release ? '' : ('-SNAPSHOT-' + System.getenv("CIRCLE_BUILD_NUM")))
|
|
group = config.group
|
|
archivesBaseName = rootProject.ext.config.name + "_" + config.minecraft_version
|
|
|
|
sourceCompatibility = targetCompatibility = 1.6
|
|
compileJava {
|
|
sourceCompatibility = targetCompatibility = 1.6
|
|
}
|
|
|
|
minecraft {
|
|
version = config.forge_mc_version + "-" + config.forge_version
|
|
runDir = "run"
|
|
mappings = config.mappings_version
|
|
|
|
replace '@MOD_VERSION@', rootProject.ext.config.version
|
|
replace '@MOD_FULL_VERSION@', project.version
|
|
replaceIn 'CustomSkinLoader.java'
|
|
}
|
|
|
|
jar {
|
|
manifest {
|
|
attributes 'TweakClass' : 'customskinloader.tweaker.ModSystemTweaker'
|
|
attributes 'TweakName' : rootProject.ext.config.name
|
|
attributes 'TweakAuthor' : 'xfl03,JLChnToZ'
|
|
attributes 'TweakVersion': version
|
|
attributes 'TweakOrder' : '-10'
|
|
}
|
|
exclude 'net/minecraft/client/renderer/texture/NativeImage.class'
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
//Common
|
|
srcDir '../Common/source'
|
|
//Vanilla
|
|
srcDir '../Vanilla'
|
|
}
|
|
resources {
|
|
//Common
|
|
srcDir '../Common/resource'
|
|
}
|
|
}
|
|
}
|
|
|
|
processResources {
|
|
expand([
|
|
modVersion : rootProject.ext.config.version,
|
|
modFullVersion: project.version,
|
|
mcVersion : config.minecraft_version,
|
|
mcFullVersions: config.minecraft_full_versions,
|
|
forgeVersion : config.forge_version,
|
|
gitVersion : System.getenv("CIRCLE_SHA1"),
|
|
buildUrl : System.getenv("CIRCLE_BUILD_URL")
|
|
])
|
|
}
|
|
task copyResources << {
|
|
def outputFile = file("src/main/resources")
|
|
outputFile.deleteDir()
|
|
copy {
|
|
from '../Common/resource'
|
|
into 'src/main/resources'
|
|
}
|
|
}
|
|
processResources.dependsOn copyResources
|
|
|
|
task afterBuild {
|
|
doLast {
|
|
//renameSrgJar
|
|
def file0 = file("build/libs/${archivesBaseName}-${version}.jar")
|
|
def file1 = file("build/libs/${archivesBaseName}-${version}-srg.jar")
|
|
file0.renameTo(file1)
|
|
|
|
//reobfSrgToNotch
|
|
reobfSrgToNotch()
|
|
|
|
//copyBuildFile
|
|
copy {
|
|
from 'build/libs'
|
|
into '../build/libs'
|
|
include '**/*.jar'
|
|
exclude '**/*-srg.jar'
|
|
exclude '**/*-dev.jar'
|
|
exclude '**/*-sources.jar'
|
|
}
|
|
}
|
|
}
|
|
build.finalizedBy afterBuild
|
|
|
|
//notch pack
|
|
void reobfSrgToNotch() {
|
|
def srgName = "${archivesBaseName}-${version}-srg.jar"
|
|
def notchName = srgName.replace('-srg', '')
|
|
if (config.srg_notch_map == null || !(config.srg_notch_map instanceof String) || config.srg_notch_map == "") {
|
|
//Default Map
|
|
def mcpName = srgName.replace('-srg', '-dev')
|
|
applySpecialSource(srgName, mcpName, getDefaultMap("srg-mcp"))
|
|
applySpecialSource(mcpName, notchName, getDefaultMap("mcp-notch"))
|
|
} else {
|
|
//Custom Map
|
|
applySpecialSource(srgName, notchName, config.srg_notch_map)
|
|
}
|
|
}
|
|
|
|
void applySpecialSource(String inputName, String outputName, String mapFile) {
|
|
def mapping = new net.md_5.specialsource.JarMapping()
|
|
def srgFile = file(mapFile)
|
|
def inputFile = file("build/libs/${inputName}")
|
|
def outputFile = file("build/libs/${outputName}")
|
|
def remapper = new net.md_5.specialsource.JarRemapper(null, mapping)
|
|
def inputJar = net.md_5.specialsource.Jar.init(inputFile)
|
|
def inheritanceProviders = new net.md_5.specialsource.provider.JointProvider()
|
|
def jarProvider = new net.md_5.specialsource.provider.JarProvider(inputJar)
|
|
inheritanceProviders.add(jarProvider)
|
|
mapping.loadMappings(srgFile)
|
|
mapping.setFallbackInheritanceProvider(inheritanceProviders)
|
|
remapper.remapJar(inputJar, outputFile)
|
|
}
|
|
|
|
String getDefaultMap(String srgType) {
|
|
def mcpVersion = minecraft.mappings.replace('_', "/")
|
|
return System.getProperty('user.home') + "/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_${mcpVersion}/${config.forge_mc_version}/srgs/${srgType}.srg"
|
|
} |