mirror of
https://github.com/GTNewHorizons/Postea.git
synced 2026-11-22 21:19:39 +00:00
Add update check in build.gradle
This commit is contained in:
1 parent
549859df01
commit
b61969b80a
1 file changed
+12
-1
+12
-1
@@ -52,12 +52,23 @@ if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
|
||||
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
|
||||
}
|
||||
|
||||
String getVersionHash(String buildScriptContent) {
|
||||
String[] lines = buildScriptContent.split("\n")
|
||||
if(lines.size() > 0 && lines[0].startsWith("//version: ")) {
|
||||
return lines[0].substring(11)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
def checkForUpdate() {
|
||||
Thread.start {
|
||||
Map parameters = [ "connectTimeout" : 2000, "readTimeout": 2000 ]
|
||||
String currentBuildScript = new File("build.gradle").getText()
|
||||
String currentBuildScriptHash = getVersionHash(currentBuildScript)
|
||||
String availableBuildScript = new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle").newInputStream(parameters).getText()
|
||||
if (availableBuildScript.equals("") == false && currentBuildScript.equals(availableBuildScript) == false) {
|
||||
String availableBuildScriptHash = getVersionHash(availableBuildScript)
|
||||
if (currentBuildScriptHash.equals("") == false && availableBuildScriptHash.equals("") == false
|
||||
&& currentBuildScriptHash.equals(availableBuildScriptHash) == false) {
|
||||
println("Build script update available! Check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user