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.2-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' /* replace '@MC_VERSION@', config.minecraft_version replace '@MC_FULL_VERSIONS@', config.minecraft_full_versions replace '@FORGE_VERSION@', config.forge_version replace '@GIT_VERSION@', System.getenv("GIT_VERSION") replace '@BUILD_URL@', System.getenv("BUILD_URL") replaceIn 'BuildInfo.json'*/ } 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' from 'src/minecraft/' into 'src/main/java' include '**/*.java' } } sourceMainJava.dependsOn copySource task copyResources << { def outputFile = file("src/main/resources") outputFile.deleteDir() copy { from '../Common' into 'src/main/resources' exclude '**/*.java' } } 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 '**/*-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" }