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", version: fuelVersion)
|
||||||
shade(group: "com.github.kittinunf.Fuel", name: "fuel-coroutines", 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.result', name: 'result', version: resultVersion)
|
||||||
|
|
||||||
// shade group: 'com.github.kittinunf.fuel', name: 'fuel', version: fuelVersion
|
// shade group: 'com.github.kittinunf.fuel', name: 'fuel', version: fuelVersion
|
||||||
|
|
|
@ -20,13 +20,14 @@ dependencies {
|
||||||
compile project(":Jankson")
|
compile project(":Jankson")
|
||||||
shadow(project(':Jankson')) { transitive = false }
|
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.google.guava', name: 'guava', version: '+'
|
||||||
|
|
||||||
compile(group: "com.github.kittinunf.Fuel", name: "fuel", version: fuelVersion)
|
compile(group: "com.github.kittinunf.Fuel", name: "fuel", version: fuelVersion)
|
||||||
shadow(group: "com.github.kittinunf.Fuel", name: "fuel", version: fuelVersion) { transitive = true }
|
shadow(group: "com.github.kittinunf.Fuel", name: "fuel", version: fuelVersion) { transitive = true }
|
||||||
compile(group: "com.github.kittinunf.Fuel", name: "fuel-coroutines", version: fuelVersion)
|
compile(group: "com.github.kittinunf.Fuel", name: "fuel-coroutines", version: fuelVersion)
|
||||||
shadow(group: "com.github.kittinunf.Fuel", name: "fuel-coroutines", version: fuelVersion) { transitive = true }
|
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)
|
// compile(group: 'com.github.kittinunf.result', name: 'result', version: resultVersion)
|
||||||
// shadow(group: 'com.github.kittinunf.result', name: 'result', version: resultVersion) { transitive = false }
|
// shadow(group: 'com.github.kittinunf.result', name: 'result', version: resultVersion) { transitive = false }
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package matterlink.jenkins
|
package matterlink.jenkins
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by nikky on 03/02/18.
|
* Created by nikky on 03/02/18.
|
||||||
* @author Nikky
|
* @author Nikky
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@JsonIgnoreProperties(ignoreUnknown = true)
|
@Serializable
|
||||||
data class Artifact(
|
data class Artifact(
|
||||||
val displayPath: String,
|
val displayPath: String,
|
||||||
val fileName: String,
|
val fileName: String,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package matterlink.jenkins
|
package matterlink.jenkins
|
||||||
|
|
||||||
import com.github.kittinunf.fuel.httpGet
|
import com.github.kittinunf.fuel.httpGet
|
||||||
|
import com.github.kittinunf.fuel.serialization.kotlinxDeserializerOf
|
||||||
import com.github.kittinunf.result.Result
|
import com.github.kittinunf.result.Result
|
||||||
import com.google.gson.Gson
|
import kotlinx.serialization.json.JSON
|
||||||
import matterlink.logger
|
import matterlink.logger
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,10 +21,10 @@ data class Build(
|
||||||
val (request, response, result) = "$url/api/json"
|
val (request, response, result) = "$url/api/json"
|
||||||
.httpGet()
|
.httpGet()
|
||||||
.header("User-Agent" to userAgent)
|
.header("User-Agent" to userAgent)
|
||||||
.responseString()
|
.responseObject(kotlinxDeserializerOf(loader = BuildWithDetails.serializer(), json = JSON.nonstrict))
|
||||||
return when (result) {
|
return when (result) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
gson.fromJson(result.value, BuildWithDetails::class.java)
|
result.value
|
||||||
}
|
}
|
||||||
is Result.Failure -> {
|
is Result.Failure -> {
|
||||||
logger.error(result.error.toString())
|
logger.error(result.error.toString())
|
||||||
|
@ -31,9 +32,5 @@ data class Build(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
val gson = Gson()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package matterlink.jenkins
|
package matterlink.jenkins
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
//@JsonIgnoreProperties(ignoreUnknown = true)
|
@Serializable
|
||||||
data class BuildWithDetails(
|
data class BuildWithDetails(
|
||||||
val number: Int,
|
val number: Int,
|
||||||
val url: String,
|
val url: String,
|
||||||
val artifacts: List<Artifact>,
|
val artifacts: List<Artifact>,
|
||||||
// @JsonFormat(shape=JsonFormat.Shape.NUMBER, pattern="s")
|
|
||||||
val timestamp: Date
|
val timestamp: Date
|
||||||
)
|
)
|
|
@ -2,8 +2,9 @@ package matterlink.jenkins
|
||||||
|
|
||||||
|
|
||||||
import com.github.kittinunf.fuel.httpGet
|
import com.github.kittinunf.fuel.httpGet
|
||||||
|
import com.github.kittinunf.fuel.serialization.kotlinxDeserializerOf
|
||||||
import com.github.kittinunf.result.Result
|
import com.github.kittinunf.result.Result
|
||||||
import com.google.gson.Gson
|
import kotlinx.serialization.json.JSON
|
||||||
import matterlink.logger
|
import matterlink.logger
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,10 +22,10 @@ class JenkinsServer(val url: String) {
|
||||||
val (_, _, result) = requestURL
|
val (_, _, result) = requestURL
|
||||||
.httpGet()
|
.httpGet()
|
||||||
.header("User-Agent" to userAgent)
|
.header("User-Agent" to userAgent)
|
||||||
.responseString()
|
.responseObject(kotlinxDeserializerOf(loader = Job.serializer(), json = JSON.nonstrict))
|
||||||
return when (result) {
|
return when (result) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
gson.fromJson(result.value, Job::class.java)
|
result.value
|
||||||
}
|
}
|
||||||
is Result.Failure -> {
|
is Result.Failure -> {
|
||||||
logger.error(result.error.toString())
|
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
|
package matterlink.jenkins
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by nikky on 03/02/18.
|
* Created by nikky on 03/02/18.
|
||||||
* @author Nikky
|
* @author Nikky
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//@JsonIgnoreProperties(ignoreUnknown = true)
|
@Serializable
|
||||||
data class Job(
|
data class Job(
|
||||||
val url: String,
|
val url: String,
|
||||||
val name: String,
|
val name: String,
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package matterlink.update
|
package matterlink.update
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
data class CurseFile(
|
data class CurseFile(
|
||||||
val downloadURL: String,
|
val downloadUrl: String,
|
||||||
val fileName: String,
|
val fileName: String,
|
||||||
|
val fileNameOnDisk: String,
|
||||||
val gameVersion: List<String>,
|
val gameVersion: List<String>,
|
||||||
val releaseType: String,
|
val releaseType: String,
|
||||||
val fileStatus: String
|
val fileStatus: String
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package matterlink.update
|
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.CoroutineName
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
import kotlinx.serialization.list
|
||||||
import matterlink.api.ApiMessage
|
import matterlink.api.ApiMessage
|
||||||
import matterlink.bridge.MessageHandlerInst
|
import matterlink.bridge.MessageHandlerInst
|
||||||
import matterlink.config.cfg
|
import matterlink.config.cfg
|
||||||
|
@ -12,9 +14,9 @@ import matterlink.handlers.LocationHandler
|
||||||
import matterlink.instance
|
import matterlink.instance
|
||||||
import matterlink.jenkins.JenkinsServer
|
import matterlink.jenkins.JenkinsServer
|
||||||
import matterlink.logger
|
import matterlink.logger
|
||||||
import java.io.BufferedReader
|
import com.github.kittinunf.fuel.serialization.kotlinxDeserializerOf
|
||||||
import java.net.HttpURLConnection
|
import com.github.kittinunf.result.Result
|
||||||
import java.net.URL
|
import kotlinx.serialization.json.JSON
|
||||||
|
|
||||||
object UpdateChecker : CoroutineScope {
|
object UpdateChecker : CoroutineScope {
|
||||||
override val coroutineContext = Job() + CoroutineName("UpdateChacker")
|
override val coroutineContext = Job() + CoroutineName("UpdateChacker")
|
||||||
|
@ -61,41 +63,30 @@ object UpdateChecker : CoroutineScope {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val gson = GsonBuilder()
|
|
||||||
// .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
|
|
||||||
.create()
|
|
||||||
|
|
||||||
logger.info("Checking for new versions...")
|
logger.info("Checking for new versions...")
|
||||||
|
val (request, response, result) = with(instance) {
|
||||||
val url = URL("https://staging_cursemeta.dries007.net/api/v3/direct/addon/287323/files")
|
|
||||||
val con = url.openConnection() as HttpURLConnection
|
|
||||||
|
|
||||||
with(instance) {
|
|
||||||
val useragent =
|
val useragent =
|
||||||
"MatterLink/$modVersion MinecraftForge/$mcVersion-$forgeVersion (https://github.com/elytra/MatterLink)"
|
"MatterLink/$modVersion MinecraftForge/$mcVersion-$forgeVersion (https://github.com/elytra/MatterLink)"
|
||||||
logger.debug("setting User-Agent: '$useragent'")
|
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 = when(result) {
|
||||||
|
is Result.Success -> {
|
||||||
val apiUpdateList = if (200 == con.responseCode) { //HTTP 200 OK
|
result.value
|
||||||
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(" ") }
|
is Result.Failure -> {
|
||||||
|
|
||||||
} else {
|
|
||||||
logger.error("Could not check for updates!")
|
logger.error("Could not check for updates!")
|
||||||
|
logger.error("cUrl: ${request.cUrlString()}")
|
||||||
|
logger.error("request: $request")
|
||||||
|
logger.error("response: $response")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
.filter { it.fileStatus == "SemiNormal" && it.gameVersion.contains(instance.mcVersion) }
|
||||||
|
|
||||||
val modVersionChunks = instance.modVersion
|
val modVersionChunks = instance.modVersion
|
||||||
.substringBefore("-dev")
|
.substringBefore("-dev")
|
||||||
|
@ -133,13 +124,13 @@ object UpdateChecker : CoroutineScope {
|
||||||
|
|
||||||
logger.info("Matterlink out of date! You are $count $version behind")
|
logger.info("Matterlink out of date! You are $count $version behind")
|
||||||
possibleUpdates.forEach {
|
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(
|
MessageHandlerInst.transmit(
|
||||||
ApiMessage(
|
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=`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 "}
|
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
|
cp -f "$FORGE_FILE" forge.jar
|
||||||
if [ ! $? -eq 0 ]; then
|
if [ ! $? -eq 0 ]; then
|
||||||
|
|
Loading…
Reference in New Issue