1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Support tasks in the IDEA plug-in.

This commit is contained in:
Cedric Beust 2016-04-25 22:09:11 -08:00
parent 1eeb34ca2a
commit a6cb4c3314
7 changed files with 81 additions and 41 deletions

View file

@ -340,6 +340,15 @@ class TaskManager @Inject constructor(val args: Args,
runAfter.forEach { runAfter(it, name) }
}
/**
* Invoked by the server whenever it's done processing a command so the state can be reset for the next command.
*/
private fun cleanUp() {
annotationTasks.clear()
dynamicTasks.clear()
taskAnnotations.clear()
}
//
// Manage the tasks
/////

View file

@ -1,5 +1,6 @@
package com.beust.kobalt.internal.remote
import com.beust.kobalt.api.Project
import com.google.gson.JsonObject
/**
@ -14,15 +15,16 @@ interface ICommand {
/**
* Run this command based on the information received from the client. When done, use
* the sender object to send back a response.
* @param initCallback The string is a path to the build file
*/
fun run(sender: ICommandSender, received: JsonObject)
fun run(sender: ICommandSender, received: JsonObject, initCallback: (String) -> List<Project>)
fun toCommandData(data: String, error: String? = null) = CommandData(name, data, error)
}
/**
* Passed to a command in its `run` method so it can send information back to the caller.
* @param The string content that will be sent in the "data" field.
* @param commandData The string content that will be sent in the "data" field.
*/
interface ICommandSender {
fun sendData(commandData: CommandData)

View file

@ -1,5 +1,6 @@
package com.beust.kobalt.internal.remote
import com.beust.kobalt.api.Project
import com.google.gson.Gson
import com.google.gson.JsonObject
@ -14,7 +15,7 @@ import com.google.gson.JsonObject
class PingCommand() : ICommand {
override val name = "ping"
override fun run(sender: ICommandSender, received: JsonObject) {
override fun run(sender: ICommandSender, received: JsonObject, initCallback: (String) -> List<Project>) {
sender.sendData(toCommandData(Gson().toJson(PingData(received.toString()))))
}