mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-14 22:37:06 -04:00
Fix: Gradle scripts aren't compatible with Java 8. (#2706)
* Fix: Gradle scripts aren't compatible with Java 8. * update --------- Co-authored-by: Glavo <zjx001202@gmail.com>
This commit is contained in:
parent
4102029d6d
commit
017d688e32
@ -101,10 +101,7 @@ tasks.getByName<JavaCompile>("compileJava") {
|
|||||||
|
|
||||||
doLast {
|
doLast {
|
||||||
Gson().also { gsonInstance ->
|
Gson().also { gsonInstance ->
|
||||||
Files.newBufferedReader(
|
rootProject.rootDir.resolve("data-json/dynamic-remote-resources-raw.json").bufferedReader().use { br ->
|
||||||
rootProject.rootDir.toPath().resolve("data-json/dynamic-remote-resources-raw.json"),
|
|
||||||
Charsets.UTF_8
|
|
||||||
).use { br ->
|
|
||||||
(gsonInstance.fromJson(br, JsonElement::class.java) as JsonObject)
|
(gsonInstance.fromJson(br, JsonElement::class.java) as JsonObject)
|
||||||
}.also { data ->
|
}.also { data ->
|
||||||
data.asMap().forEach { (namespace, namespaceData) ->
|
data.asMap().forEach { (namespace, namespaceData) ->
|
||||||
@ -117,7 +114,7 @@ tasks.getByName<JavaCompile>("compileJava") {
|
|||||||
|
|
||||||
val currentSha1 = digest(
|
val currentSha1 = digest(
|
||||||
"SHA-1",
|
"SHA-1",
|
||||||
Files.readAllBytes(rootProject.rootDir.toPath().resolve(localPath))
|
rootProject.rootDir.resolve(localPath).readBytes()
|
||||||
).joinToString(separator = "") { "%02x".format(it) }
|
).joinToString(separator = "") { "%02x".format(it) }
|
||||||
|
|
||||||
if (!sha1.equals(currentSha1, ignoreCase = true)) {
|
if (!sha1.equals(currentSha1, ignoreCase = true)) {
|
||||||
@ -127,20 +124,20 @@ tasks.getByName<JavaCompile>("compileJava") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rootProject.rootDir.toPath().resolve("data-json/dynamic-remote-resources.json").also { zippedPath ->
|
rootProject.rootDir.resolve("data-json/dynamic-remote-resources.json").also { zippedPath ->
|
||||||
gsonInstance.toJson(data).also { expectedData ->
|
gsonInstance.toJson(data).also { expectedData ->
|
||||||
if (Files.exists(zippedPath)) {
|
if (zippedPath.exists()) {
|
||||||
Files.readString(zippedPath, Charsets.UTF_8).also { rawData ->
|
zippedPath.readText().also { rawData ->
|
||||||
if (!rawData.equals(expectedData)) {
|
if (rawData != expectedData) {
|
||||||
if (System.getenv("GITHUB_SHA") == null) {
|
if (System.getenv("GITHUB_SHA") == null) {
|
||||||
Files.writeString(zippedPath, expectedData, Charsets.UTF_8)
|
zippedPath.writeText(expectedData)
|
||||||
} else {
|
} else {
|
||||||
throw IllegalStateException("Mismatched zipped dynamic-remote-resources json file!")
|
throw IllegalStateException("Mismatched zipped dynamic-remote-resources json file!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Files.writeString(zippedPath, expectedData, Charsets.UTF_8)
|
zippedPath.writeText(expectedData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user