remove gson dependency, update dependency checks
This commit is contained in:
parent
43ce9491b9
commit
b12704d507
|
@ -40,6 +40,7 @@ dependencies {
|
|||
|
||||
shade(group: "com.github.kittinunf.Fuel", name: "fuel", version: fuelVersion)
|
||||
shade(group: "com.github.kittinunf.Fuel", name: "fuel-coroutines", version: fuelVersion)
|
||||
shade(group: "com.github.kittinunf.Fuel", name: "fuel-kotlinx-serialization", version: fuelVersion)
|
||||
shade(group: 'com.github.kittinunf.result', name: 'result', version: resultVersion)
|
||||
|
||||
// shade group: 'com.github.kittinunf.fuel', name: 'fuel', version: fuelVersion
|
||||
|
|
|
@ -20,13 +20,14 @@ dependencies {
|
|||
compile project(":Jankson")
|
||||
shadow(project(':Jankson')) { transitive = false }
|
||||
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '+'
|
||||
compile group: 'com.google.guava', name: 'guava', version: '+'
|
||||
|
||||
compile(group: "com.github.kittinunf.Fuel", name: "fuel", version: fuelVersion)
|
||||
shadow(group: "com.github.kittinunf.Fuel", name: "fuel", version: fuelVersion) { transitive = true }
|
||||
compile(group: "com.github.kittinunf.Fuel", name: "fuel-coroutines", version: fuelVersion)
|
||||
shadow(group: "com.github.kittinunf.Fuel", name: "fuel-coroutines", version: fuelVersion) { transitive = true }
|
||||
compile(group: "com.github.kittinunf.Fuel", name: "fuel-kotlinx-serialization", version: fuelVersion)
|
||||
shadow(group: "com.github.kittinunf.Fuel", name: "fuel-kotlinx-serialization", version: fuelVersion) { transitive = true }
|
||||
// compile(group: 'com.github.kittinunf.result', name: 'result', version: resultVersion)
|
||||
// shadow(group: 'com.github.kittinunf.result', name: 'result', version: resultVersion) { transitive = false }
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package matterlink.jenkins
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Created by nikky on 03/02/18.
|
||||
* @author Nikky
|
||||
*/
|
||||
|
||||
//@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@Serializable
|
||||
data class Artifact(
|
||||
val displayPath: String,
|
||||
val fileName: String,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package matterlink.jenkins
|
||||
|
||||
import com.github.kittinunf.fuel.httpGet
|
||||
import com.github.kittinunf.fuel.serialization.kotlinxDeserializerOf
|
||||
import com.github.kittinunf.result.Result
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.serialization.json.JSON
|
||||
import matterlink.logger
|
||||
|
||||
|
||||
|
@ -20,10 +21,10 @@ data class Build(
|
|||
val (request, response, result) = "$url/api/json"
|
||||
.httpGet()
|
||||
.header("User-Agent" to userAgent)
|
||||
.responseString()
|
||||
.responseObject(kotlinxDeserializerOf(loader = BuildWithDetails.serializer(), json = JSON.nonstrict))
|
||||
return when (result) {
|
||||
is Result.Success -> {
|
||||
gson.fromJson(result.value, BuildWithDetails::class.java)
|
||||
result.value
|
||||
}
|
||||
is Result.Failure -> {
|
||||
logger.error(result.error.toString())
|
||||
|
@ -31,9 +32,5 @@ data class Build(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val gson = Gson()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package matterlink.jenkins
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.util.Date
|
||||
|
||||
//@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@Serializable
|
||||
data class BuildWithDetails(
|
||||
val number: Int,
|
||||
val url: String,
|
||||
val artifacts: List<Artifact>,
|
||||
// @JsonFormat(shape=JsonFormat.Shape.NUMBER, pattern="s")
|
||||
val timestamp: Date
|
||||
)
|
|
@ -2,8 +2,9 @@ package matterlink.jenkins
|
|||
|
||||
|
||||
import com.github.kittinunf.fuel.httpGet
|
||||
import com.github.kittinunf.fuel.serialization.kotlinxDeserializerOf
|
||||
import com.github.kittinunf.result.Result
|
||||
import com.google.gson.Gson
|
||||
import kotlinx.serialization.json.JSON
|
||||
import matterlink.logger
|
||||
|
||||
/**
|
||||
|
@ -21,10 +22,10 @@ class JenkinsServer(val url: String) {
|
|||
val (_, _, result) = requestURL
|
||||
.httpGet()
|
||||
.header("User-Agent" to userAgent)
|
||||
.responseString()
|
||||
.responseObject(kotlinxDeserializerOf(loader = Job.serializer(), json = JSON.nonstrict))
|
||||
return when (result) {
|
||||
is Result.Success -> {
|
||||
gson.fromJson(result.value, Job::class.java)
|
||||
result.value
|
||||
}
|
||||
is Result.Failure -> {
|
||||
logger.error(result.error.toString())
|
||||
|
@ -33,8 +34,4 @@ class JenkinsServer(val url: String) {
|
|||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val gson = Gson()
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package matterlink.jenkins
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Created by nikky on 03/02/18.
|
||||
* @author Nikky
|
||||
*/
|
||||
|
||||
//@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@Serializable
|
||||
data class Job(
|
||||
val url: String,
|
||||
val name: String,
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package matterlink.update
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class CurseFile(
|
||||
val downloadURL: String,
|
||||
val downloadUrl: String,
|
||||
val fileName: String,
|
||||
val fileNameOnDisk: String,
|
||||
val gameVersion: List<String>,
|
||||
val releaseType: String,
|
||||
val fileStatus: String
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package matterlink.update
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.github.kittinunf.fuel.core.extensions.cUrlString
|
||||
import com.github.kittinunf.fuel.httpGet
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.serialization.list
|
||||
import matterlink.api.ApiMessage
|
||||
import matterlink.bridge.MessageHandlerInst
|
||||
import matterlink.config.cfg
|
||||
|
@ -12,9 +14,9 @@ import matterlink.handlers.LocationHandler
|
|||
import matterlink.instance
|
||||
import matterlink.jenkins.JenkinsServer
|
||||
import matterlink.logger
|
||||
import java.io.BufferedReader
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import com.github.kittinunf.fuel.serialization.kotlinxDeserializerOf
|
||||
import com.github.kittinunf.result.Result
|
||||
import kotlinx.serialization.json.JSON
|
||||
|
||||
object UpdateChecker : CoroutineScope {
|
||||
override val coroutineContext = Job() + CoroutineName("UpdateChacker")
|
||||
|
@ -61,41 +63,30 @@ object UpdateChecker : CoroutineScope {
|
|||
return
|
||||
}
|
||||
|
||||
val gson = GsonBuilder()
|
||||
// .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
|
||||
.create()
|
||||
|
||||
logger.info("Checking for new versions...")
|
||||
|
||||
val url = URL("https://staging_cursemeta.dries007.net/api/v3/direct/addon/287323/files")
|
||||
val con = url.openConnection() as HttpURLConnection
|
||||
|
||||
with(instance) {
|
||||
val (request, response, result) = with(instance) {
|
||||
val useragent =
|
||||
"MatterLink/$modVersion MinecraftForge/$mcVersion-$forgeVersion (https://github.com/elytra/MatterLink)"
|
||||
logger.debug("setting User-Agent: '$useragent'")
|
||||
con.setRequestProperty("User-Agent", useragent)
|
||||
|
||||
"https://curse.nikky.moe/api/addon/287323/files".httpGet()
|
||||
.header("User-Agent" to useragent)
|
||||
.responseObject(kotlinxDeserializerOf(loader = CurseFile.serializer().list, json = JSON.nonstrict))
|
||||
}
|
||||
|
||||
con.connect()
|
||||
|
||||
val apiUpdateList = if (200 == con.responseCode) { //HTTP 200 OK
|
||||
val buffer: BufferedReader = con.inputStream.bufferedReader()
|
||||
|
||||
//put all of the buffer content onto the string
|
||||
val content = buffer.readText()
|
||||
logger.trace("updateData: $content")
|
||||
|
||||
gson.fromJson(content, Array<CurseFile>::class.java)
|
||||
.filter {
|
||||
it.fileStatus == "SemiNormal" && it.gameVersion.contains(instance.mcVersion)
|
||||
}
|
||||
.sortedByDescending { it.fileName.substringAfterLast(" ") }
|
||||
|
||||
} else {
|
||||
logger.error("Could not check for updates!")
|
||||
return
|
||||
val apiUpdateList = when(result) {
|
||||
is Result.Success -> {
|
||||
result.value
|
||||
}
|
||||
is Result.Failure -> {
|
||||
logger.error("Could not check for updates!")
|
||||
logger.error("cUrl: ${request.cUrlString()}")
|
||||
logger.error("request: $request")
|
||||
logger.error("response: $response")
|
||||
return
|
||||
}
|
||||
}
|
||||
.filter { it.fileStatus == "SemiNormal" && it.gameVersion.contains(instance.mcVersion) }
|
||||
|
||||
val modVersionChunks = instance.modVersion
|
||||
.substringBefore("-dev")
|
||||
|
@ -133,13 +124,13 @@ object UpdateChecker : CoroutineScope {
|
|||
|
||||
logger.info("Matterlink out of date! You are $count $version behind")
|
||||
possibleUpdates.forEach {
|
||||
logger.info("version: ${it.fileName} download: ${it.downloadURL}")
|
||||
logger.info("version: ${it.fileName} download: ${it.downloadUrl}")
|
||||
}
|
||||
|
||||
logger.warn("Mod out of date! New $version available at ${latest.downloadURL}")
|
||||
logger.warn("Mod out of date! New $version available at ${latest.downloadUrl}")
|
||||
MessageHandlerInst.transmit(
|
||||
ApiMessage(
|
||||
text = "MatterLink out of date! You are $count $version behind! Please download new version from ${latest.downloadURL}"
|
||||
text = "MatterLink out of date! You are $count $version behind! Please download new version from ${latest.downloadUrl}"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ java -jar forge-installer.jar --installServer
|
|||
|
||||
FORGE_FILE=`grep "The server installed successfully, you should now be able to run the file " forge-installer.jar.log | tail -1`
|
||||
FORGE_FILE=${FORGE_FILE#"The server installed successfully, you should now be able to run the file "}
|
||||
echo FORGE_FILE
|
||||
echo $FORGE_FILE
|
||||
|
||||
cp -f "$FORGE_FILE" forge.jar
|
||||
if [ ! $? -eq 0 ]; then
|
||||
|
|
Loading…
Reference in New Issue