mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-21 01:02:16 +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
|
||||
}
|
||||
Reference in new issue
Block a user