mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-12 04:57:33 +00:00
142 lines
4.6 KiB
Groovy
142 lines
4.6 KiB
Groovy
buildscript {
|
|
repositories {
|
|
/*
|
|
maven {
|
|
name = "fmm"
|
|
url = "http://forgemavenmirror.sinaapp.com/maven"
|
|
}
|
|
*/
|
|
jcenter()
|
|
maven {
|
|
name = "forge"
|
|
url = "http://files.minecraftforge.net/maven"
|
|
}
|
|
maven {
|
|
name = "sonatype"
|
|
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
}
|
|
}
|
|
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
|
|
}
|
|
//Example: 14.4a-SNAPSHOT-20160820
|
|
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + ((rootProject.ext.config.snapshot==""||rootProject.ext.config.snapshot=="0"||rootProject.ext.config.snapshot==0)?'':('-SNAPSHOT-'+System.getenv("BUILD_NUMBER")))
|
|
group = config.group
|
|
archivesBaseName = rootProject.ext.config.name+"_"+config.minecraft_version
|
|
|
|
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'
|
|
}
|
|
}
|
|
|
|
task copySource << {
|
|
def outputFile = file("src/main/java")
|
|
outputFile.deleteDir()
|
|
copy {
|
|
from '../Common/source'
|
|
from 'src/minecraft/'
|
|
into 'src/main/java'
|
|
}
|
|
}
|
|
sourceMainJava.dependsOn copySource
|
|
|
|
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("GIT_COMMIT"),
|
|
buildUrl:System.getenv("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 << {
|
|
//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"
|
|
} |