mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-22 03:52:15 +00:00
Modify gradle script
This commit is contained in:
1 parent
e3020dad00
commit
fbd06f147a
6 files changed
+175
-98
No files matched your search
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Gradle Script for COS
|
||||
* It can be used to upload or download file from Tencent Cloud COS.
|
||||
* COS: https://cloud.tencent.com/document/product/436
|
||||
*/
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.qcloud:cos_api:5.4.6'
|
||||
}
|
||||
}
|
||||
|
||||
import com.qcloud.cos.COSClient
|
||||
import com.qcloud.cos.ClientConfig
|
||||
import com.qcloud.cos.auth.BasicCOSCredentials
|
||||
import com.qcloud.cos.auth.COSCredentials
|
||||
import com.qcloud.cos.model.PutObjectRequest
|
||||
import com.qcloud.cos.region.Region
|
||||
|
||||
String getKey(String filename) {
|
||||
String name = filename.substring(0, filename.lastIndexOf('.'))
|
||||
if (filename.endsWith(".json"))
|
||||
return String.format(
|
||||
"versions/%s/%s",
|
||||
name,
|
||||
filename
|
||||
)
|
||||
if (filename.endsWith(".jar"))
|
||||
return String.format(
|
||||
"libraries/customskinloader/%s/%s/%s",
|
||||
name.substring(0, name.indexOf('-')),
|
||||
name.substring(name.indexOf('-') + 1),
|
||||
filename
|
||||
)
|
||||
return filename
|
||||
}
|
||||
|
||||
void uploadFileToCOS(String key, File file) {
|
||||
COSCredentials cred = new BasicCOSCredentials(System.getenv("COS_SECRET_ID"), System.getenv("COS_SECRET_KEY"))
|
||||
ClientConfig clientConfig = new ClientConfig(new Region("ap-shanghai"))
|
||||
COSClient cosClient = new COSClient(cred, clientConfig)
|
||||
String bucketName = System.getenv("COS_BUCKET")
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file)
|
||||
cosClient.putObject(putObjectRequest)
|
||||
println("Uploaded to COS: " + key)
|
||||
}
|
||||
|
||||
void uploadFileToCOS(File file) {
|
||||
uploadFileToCOS(getKey(file.getName()), file)
|
||||
}
|
||||
|
||||
ext {
|
||||
uploadFileToCOS = this.&uploadFileToCOS
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Gradle Script for Remap
|
||||
* Designed for remapping jar.
|
||||
* Remap Jar: mcp<->srg<->notch
|
||||
*/
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
import net.md_5.specialsource.JarMapping
|
||||
import net.md_5.specialsource.JarRemapper
|
||||
import net.md_5.specialsource.provider.JarProvider
|
||||
import net.md_5.specialsource.provider.JointProvider
|
||||
|
||||
|
||||
void reobfSrgToNotch() {
|
||||
def srgName = "${archivesBaseName}-${version}-srg.jar"
|
||||
def notchName = srgName.replace('-srg', '')
|
||||
if (config.srg_notch_map == null) {
|
||||
//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 JarMapping()
|
||||
def srgFile = file(mapFile)
|
||||
def inputFile = file("build/libs/${inputName}")
|
||||
def outputFile = file("build/libs/${outputName}")
|
||||
def remapper = new JarRemapper(null, mapping)
|
||||
def inputJar = net.md_5.specialsource.Jar.init(inputFile)
|
||||
def inheritanceProviders = new JointProvider()
|
||||
def jarProvider = new 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"
|
||||
}
|
||||
|
||||
ext {
|
||||
reobfSrgToNotch = this.&reobfSrgToNotch
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Gradle Script for Version
|
||||
* Format Version String
|
||||
*/
|
||||
|
||||
boolean isRelease() {
|
||||
String s = rootProject.ext.config.snapshot
|
||||
return s == null || s == "" || s == "0"
|
||||
}
|
||||
|
||||
boolean isSnapshot() {
|
||||
return !isRelease()
|
||||
}
|
||||
|
||||
String getBuildNum() {
|
||||
if (System.getenv("CIRCLE_BUILD_NUM") != null)
|
||||
return System.getenv("CIRCLE_BUILD_NUM")
|
||||
return "00"
|
||||
}
|
||||
|
||||
//Example: 14.4a-SNAPSHOT-20160820
|
||||
String getCSLVersion() {
|
||||
return rootProject.ext.config.version + rootProject.ext.config.dev_version +
|
||||
(isRelease() ? '' : ('-SNAPSHOT-' + getBuildNum()))
|
||||
}
|
||||
|
||||
//Example: 14.4a-S-20160820
|
||||
String getShortVersion() {
|
||||
return getVersion().replace("SNAPSHOT", "S")
|
||||
}
|
||||
|
||||
ext {
|
||||
getCSLVersion = this.&getCSLVersion
|
||||
getShortVersion = this.&getShortVersion
|
||||
}
|
||||
+2
-2
@@ -18,10 +18,10 @@ ext.FORGE_VERSION = "14.23.4.2705"
|
||||
ext.MAPPING_VERSION = "stable_39"
|
||||
ext.MINECRAFT_FULL_VERSIONS = "1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2"
|
||||
|
||||
ext.snapshot = !(rootProject.ext.config.snapshot == "" || rootProject.ext.config.snapshot == "0" || rootProject.ext.config.snapshot == 0)
|
||||
apply from: rootProject.file("BuildScripts/version.gradle")
|
||||
|
||||
archivesBaseName = "CustomSkinLoader_Forge"
|
||||
version = rootProject.ext.config.version + rootProject.ext.config.dev_version + (snapshot ? "-SNAPSHOT-" + System.getenv("CIRCLE_BUILD_NUM") : "")
|
||||
version = getCSLVersion()
|
||||
group = "customskinloader"
|
||||
|
||||
sourceCompatibility = targetCompatibility = 1.6
|
||||
|
||||
+3
-46
@@ -2,7 +2,6 @@ apply plugin: 'base'
|
||||
|
||||
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
|
||||
@@ -18,7 +17,6 @@ buildscript {
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
||||
classpath 'com.qcloud:cos_api:5.4.6'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,43 +25,7 @@ subprojects {
|
||||
apply from: rootProject.file('common.gradle')
|
||||
}
|
||||
|
||||
/* COS Upload Begin */
|
||||
import com.qcloud.cos.COSClient
|
||||
import com.qcloud.cos.ClientConfig
|
||||
import com.qcloud.cos.auth.BasicCOSCredentials
|
||||
import com.qcloud.cos.auth.COSCredentials
|
||||
import com.qcloud.cos.region.Region
|
||||
import com.qcloud.cos.model.PutObjectRequest
|
||||
|
||||
static String getLibKey(String filename) {
|
||||
String name = filename.substring(0, filename.lastIndexOf('.'))
|
||||
return String.format(
|
||||
"libraries/customskinloader/%s/%s/%s",
|
||||
name.substring(0, name.indexOf('-')),
|
||||
name.substring(name.indexOf('-') + 1),
|
||||
filename
|
||||
)
|
||||
}
|
||||
|
||||
static String getVersionKey(String filename) {
|
||||
String name = filename.substring(0, filename.lastIndexOf('.'))
|
||||
return String.format(
|
||||
"versions/%s/%s",
|
||||
name,
|
||||
filename
|
||||
)
|
||||
}
|
||||
|
||||
static void uploadFileToCOS(String key, File file) {
|
||||
COSCredentials cred = new BasicCOSCredentials(System.getenv("COS_SECRET_ID"), System.getenv("COS_SECRET_KEY"))
|
||||
ClientConfig clientConfig = new ClientConfig(new Region("ap-shanghai"))
|
||||
COSClient cosClient = new COSClient(cred, clientConfig)
|
||||
String bucketName = System.getenv("COS_BUCKET")
|
||||
|
||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, key, file)
|
||||
cosClient.putObject(putObjectRequest)
|
||||
println("Uploaded to COS: " + key)
|
||||
}
|
||||
apply from: rootProject.file('BuildScripts/cos.gradle')
|
||||
|
||||
task upload {
|
||||
doLast {
|
||||
@@ -71,12 +33,7 @@ task upload {
|
||||
if (!dir.isDirectory()) return
|
||||
File[] files = dir.listFiles()
|
||||
for (file in files) {
|
||||
String name = file.getName()
|
||||
uploadFileToCOS(
|
||||
name.endsWith("jar") ? getLibKey(name) : getVersionKey(name),
|
||||
file
|
||||
)
|
||||
uploadFileToCOS(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
/* COS Upload End */
|
||||
}
|
||||
+16
-50
@@ -15,18 +15,16 @@ 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")))
|
||||
apply from: rootProject.file("BuildScripts/version.gradle")
|
||||
|
||||
version = getCSLVersion()
|
||||
group = config.group
|
||||
archivesBaseName = rootProject.ext.config.name + "_" + config.minecraft_version
|
||||
ext.shortFullVersion = ((String) project.version).replace("SNAPSHOT", "S");
|
||||
ext.shortVersion = getShortVersion()
|
||||
|
||||
sourceCompatibility = targetCompatibility = 1.6
|
||||
compileJava {
|
||||
@@ -73,7 +71,7 @@ processResources {
|
||||
expand([
|
||||
modVersion : rootProject.ext.config.version,
|
||||
modFullVersion : project.version,
|
||||
modShortFullVersion: shortFullVersion,
|
||||
modShortFullVersion: shortVersion,
|
||||
mcVersion : config.minecraft_version,
|
||||
mcFullVersions : config.minecraft_full_versions,
|
||||
forgeVersion : config.forge_version,
|
||||
@@ -81,16 +79,19 @@ processResources {
|
||||
buildUrl : System.getenv("CIRCLE_BUILD_URL")
|
||||
])
|
||||
}
|
||||
task copyResources << {
|
||||
def outputFile = file("src/main/resources")
|
||||
outputFile.deleteDir()
|
||||
copy {
|
||||
from '../Common/resource'
|
||||
into 'src/main/resources'
|
||||
task copyResources {
|
||||
doLast {
|
||||
def outputFile = file("src/main/resources")
|
||||
outputFile.deleteDir()
|
||||
copy {
|
||||
from '../Common/resource'
|
||||
into 'src/main/resources'
|
||||
}
|
||||
}
|
||||
}
|
||||
processResources.dependsOn copyResources
|
||||
|
||||
apply from: rootProject.file("BuildScripts/remap.gradle")
|
||||
task afterBuild {
|
||||
doLast {
|
||||
//renameSrgJar
|
||||
@@ -113,45 +114,10 @@ task afterBuild {
|
||||
|
||||
//copyProfileJson
|
||||
File f = project.file("build/resources/main/Profile.json")
|
||||
String of = String.format("build/libs/%s-CSL-%s.json", config.minecraft_version, shortFullVersion)
|
||||
String of = String.format("build/libs/%s-CSL-%s.json", config.minecraft_version, shortVersion)
|
||||
File off = rootProject.file(of)
|
||||
off.parentFile.mkdirs()
|
||||
f.renameTo(off)
|
||||
}
|
||||
}
|
||||
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"
|
||||
}
|
||||
build.finalizedBy afterBuild
|
||||
Reference in new issue
Block a user