mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
JSON work.
This commit is contained in:
parent
9b206d4dc5
commit
457f190eb3
1 changed files with 16 additions and 7 deletions
|
@ -8,6 +8,8 @@ import com.beust.kobalt.maven.MavenDependency
|
||||||
import com.beust.kobalt.misc.KobaltExecutors
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
import com.beust.kobalt.misc.log
|
import com.beust.kobalt.misc.log
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.JsonObject
|
||||||
|
import com.google.gson.JsonParser
|
||||||
import com.google.inject.Inject
|
import com.google.inject.Inject
|
||||||
import java.io.BufferedReader
|
import java.io.BufferedReader
|
||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
|
@ -54,7 +56,7 @@ public class KobaltServer @Inject constructor(val args: Args, val executors: Kob
|
||||||
override fun run() = sendInfo("{ \"response\" : \"$s\" }")
|
override fun run() = sendInfo("{ \"response\" : \"$s\" }")
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class GetDependenciesCommand(val s: String) : Command {
|
inner class GetDependenciesCommand() : Command {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
val buildFile = BuildFile(Paths.get("c:\\Users\\cbeust\\java\\jcommander\\Build.kt"), "JCommander build")
|
val buildFile = BuildFile(Paths.get("c:\\Users\\cbeust\\java\\jcommander\\Build.kt"), "JCommander build")
|
||||||
val scriptCompiler = buildFileCompilerFactory.create(listOf(buildFile))
|
val scriptCompiler = buildFileCompilerFactory.create(listOf(buildFile))
|
||||||
|
@ -92,22 +94,29 @@ public class KobaltServer @Inject constructor(val args: Args, val executors: Kob
|
||||||
project.testDependencies.map { toDependencyData(it) },
|
project.testDependencies.map { toDependencyData(it) },
|
||||||
project.testProvidedDependencies.map { toDependencyData(it) }))
|
project.testProvidedDependencies.map { toDependencyData(it) }))
|
||||||
}
|
}
|
||||||
log(1, "Returning JSON for BuildScriptInfo")
|
log(1, "Returning BuildScriptInfo")
|
||||||
val result = Gson().toJson(GetDependenciesData(projects))
|
val result = Gson().toJson(GetDependenciesData(projects))
|
||||||
|
log(2, " $result")
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCommand(command: String): Command? {
|
private val COMMANDS = hashMapOf<String, Command>(
|
||||||
if (command == "g") {
|
Pair("GetDependencies", GetDependenciesCommand())
|
||||||
return GetDependenciesCommand(command)
|
)
|
||||||
|
|
||||||
|
private fun getCommand(json: String): Command? {
|
||||||
|
val jo = JsonParser().parse(json) as JsonObject
|
||||||
|
val command = jo.get("name").asString
|
||||||
|
if (command != null) {
|
||||||
|
return COMMANDS.getOrElse(command, { PingCommand(command) })
|
||||||
} else {
|
} else {
|
||||||
return PingCommand(command)
|
error("Did not find a name in command: $json")
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendInfo(info: String) {
|
fun sendInfo(info: String) {
|
||||||
if (outgoing != null) {
|
if (outgoing != null) {
|
||||||
// val json = toJson(info, executors.miscExecutor)
|
|
||||||
outgoing!!.println(info)
|
outgoing!!.println(info)
|
||||||
} else {
|
} else {
|
||||||
log(1, "Queuing $info")
|
log(1, "Queuing $info")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue