mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
Feat: Auto download client jar and dependence
This commit is contained in:
1 parent
fdeec2a2f5
commit
70d8a854ea
6 files changed
+102
-4
No files matched your search
@@ -29,8 +29,8 @@ dependencies {
|
|||||||
// never loads these classes.
|
// never loads these classes.
|
||||||
compileOnly files('../libraries/lwjgl-2.9.4-nightly-20150209.jar')
|
compileOnly files('../libraries/lwjgl-2.9.4-nightly-20150209.jar')
|
||||||
|
|
||||||
compileOnly files("../libraries/Minecraft26.2.jar")
|
compileOnly files("../libraries/minecraft/Minecraft26.2.jar")
|
||||||
compileOnly files("../libraries/brigadier-1.3.10.jar")
|
compileOnly files("../libraries/minecraft/com/mojang/brigadier/1.3.10/brigadier-1.3.10.jar")
|
||||||
|
|
||||||
// JuiceAgent is provided at runtime by the agent (see JuiceAgentBridge).
|
// JuiceAgent is provided at runtime by the agent (see JuiceAgentBridge).
|
||||||
// Do NOT bundle it: Fabric's KnotClassLoader would load a second copy of
|
// Do NOT bundle it: Fabric's KnotClassLoader would load a second copy of
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'base'
|
id 'base'
|
||||||
}
|
}
|
||||||
|
apply from: 'gradle/dependencies.gradle'
|
||||||
|
|
||||||
def outputDir = layout.projectDirectory.dir('out/tmp')
|
def outputDir = layout.projectDirectory.dir('out/tmp')
|
||||||
def distDir = layout.projectDirectory.dir('out')
|
def distDir = layout.projectDirectory.dir('out')
|
||||||
@@ -45,6 +46,7 @@ tasks.register('injectionZip', Zip) {
|
|||||||
tasks.register('packageAll') {
|
tasks.register('packageAll') {
|
||||||
group = 'build'
|
group = 'build'
|
||||||
description = 'Builds Loader, OrangeX and Injector, then zips out/tmp into out/injection.zip'
|
description = 'Builds Loader, OrangeX and Injector, then zips out/tmp into out/injection.zip'
|
||||||
|
dependsOn downloadDependencies
|
||||||
dependsOn cleanOut
|
dependsOn cleanOut
|
||||||
dependsOn ':Loader:shadowJar', ':OrangeX:shadowJar', ':Injector:jar'
|
dependsOn ':Loader:shadowJar', ':OrangeX:shadowJar', ':Injector:jar'
|
||||||
dependsOn injectionZip
|
dependsOn injectionZip
|
||||||
@@ -70,3 +72,9 @@ subprojects {
|
|||||||
mustRunAfter rootProject.tasks.named('cleanOut')
|
mustRunAfter rootProject.tasks.named('cleanOut')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gradle.taskGraph.whenReady { taskGraph ->
|
||||||
|
if (taskGraph.hasTask(':build')) {
|
||||||
|
throw new GradleException('---> The build task is not supported. Please refer to the documentation. <---')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
import java.security.MessageDigest
|
||||||
|
|
||||||
|
def downloadFiles = [
|
||||||
|
[
|
||||||
|
name: 'Minecraft26.2.jar',
|
||||||
|
url: 'https://piston-data.mojang.com/v1/objects/2dc72797acbc1b63fc16a11c4ac393605f453754/client.jar',
|
||||||
|
path: 'libraries/minecraft/Minecraft26.2.jar',
|
||||||
|
sha1: '2dc72797acbc1b63fc16a11c4ac393605f453754'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
name: 'brigadier-1.3.10.jar',
|
||||||
|
url: 'https://libraries.minecraft.net/com/mojang/brigadier/1.3.10/brigadier-1.3.10.jar',
|
||||||
|
path: 'libraries/minecraft/com/mojang/brigadier/1.3.10/brigadier-1.3.10.jar',
|
||||||
|
sha1: 'd15b53a14cf20fdcaa98f731af5dda654452c010'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
def downloadDependencies = tasks.register('downloadDependencies') {
|
||||||
|
outputs.files(downloadFiles.collect {
|
||||||
|
rootProject.file(it.path)
|
||||||
|
})
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
downloadFiles.each { dependency ->
|
||||||
|
File target = rootProject.file(dependency.path)
|
||||||
|
|
||||||
|
if (target.exists()) {
|
||||||
|
String checksum = MessageDigest.getInstance('SHA-1')
|
||||||
|
.digest(target.bytes)
|
||||||
|
.encodeHex()
|
||||||
|
.toString()
|
||||||
|
|
||||||
|
if (checksum == dependency.sha1) {
|
||||||
|
println "[OrangeX] Already downloaded: ${dependency.name}"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target.parentFile.mkdirs()
|
||||||
|
|
||||||
|
File temp = new File(target.parentFile, target.name + '.tmp')
|
||||||
|
|
||||||
|
try {
|
||||||
|
println "[OrangeX] Downloading: ${dependency.name}"
|
||||||
|
|
||||||
|
def connection = new URL(dependency.url).openConnection()
|
||||||
|
connection.connectTimeout = 15000
|
||||||
|
connection.readTimeout = 120000
|
||||||
|
|
||||||
|
connection.inputStream.withCloseable { input ->
|
||||||
|
temp.withOutputStream { output ->
|
||||||
|
output << input
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String checksum = MessageDigest.getInstance('SHA-1')
|
||||||
|
.digest(temp.bytes)
|
||||||
|
.encodeHex()
|
||||||
|
.toString()
|
||||||
|
|
||||||
|
if (checksum != dependency.sha1) {
|
||||||
|
throw new GradleException(
|
||||||
|
"SHA-1 mismatch: ${dependency.name}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!temp.renameTo(target)) {
|
||||||
|
throw new GradleException(
|
||||||
|
"Failed to move: ${dependency.name}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
println "[OrangeX] Downloaded: ${dependency.name}"
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
temp.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named('build') {
|
||||||
|
dependsOn downloadDependencies
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.subprojects {
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
dependsOn downloadDependencies
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
Minecraft26.2.jar
|
minecraft/
|
||||||
@@ -1 +0,0 @@
|
|||||||
https://piston-data.mojang.com/v1/objects/2dc72797acbc1b63fc16a11c4ac393605f453754/client.jar
|
|
||||||
Binary file not shown.
Reference in new issue
Block a user