Repository navigation
EN 05 dev loop
Once the indicator is on the canvas, the main pain is the "rebuild → copy the JAR → restart Velitask" cycle. Plugins are loaded only when the application starts, so a restart can't be avoided, but you can hand it over to the build. This is what the Dev API is for — a local HTTP address; on a request to it, the running application restarts and loads the fresh JAR.
- Open Tools → Settings... and select the Plugins category.
- In the Dev API (HTTP) section, enable Enable local API for plugin reload (off by default).
- The default port is
19809(you can change it).
The request address (the settings window shows it too):
GET http://127.0.0.1:19809/api/plugins/v1/plugin/reload/{uid}
{uid} is your plugin's identifier (the one returned by getUID()). Requests are accepted only from this computer (127.0.0.1). In response to a request, the application restarts as a whole and loads all plugins again — a single plugin can't be reloaded without a restart.
Add a task to build.gradle that builds the JAR, places it in the plugins folder, and sends a request to the Dev API (put your plugin's identifier into uid):
tasks.register('installAndReload') {
group = 'velitask'
description = 'Build jar, install it, and restart a running Velitask'
dependsOn 'jar'
doLast {
def home = System.getProperty('user.home')
def pluginsDir = file("${home}/.velitask/telemitri/plugins")
pluginsDir.mkdirs()
def srcJar = jar.archiveFile.get().asFile
def dstJar = new File(pluginsDir, srcJar.name)
dstJar.bytes = srcJar.bytes
logger.lifecycle("[installAndReload] installed: ${dstJar}")
def port = (project.findProperty('devApiPort') ?: '19809') as int
def uid = 'com.example.myplugin' // your plugin uid (same as getUID())
def url = new URL("http://127.0.0.1:${port}/api/plugins/v1/plugin/reload/${uid}")
try {
def conn = (HttpURLConnection) url.openConnection()
conn.requestMethod = 'GET'
conn.connectTimeout = 3000
conn.readTimeout = 65000
logger.lifecycle("[installAndReload] ${url} → ${conn.responseCode}")
} catch (Throwable ex) {
logger.warn("[installAndReload] restart skipped: ${ex.message} (is Velitask running? Dev API enabled?)")
}
}
}
tasks.named('build').configure { finalizedBy 'installAndReload' }The last line runs the task after every build: the IDE's Build button runs gradle build, and therefore installAndReload too.
If you have added your project's build/libs folder in the settings (see Install and run), there's no need to copy the JAR — sending the request is enough. In that case remove the lines with pluginsDir, srcJar, and dstJar from the task.
- Velitask is running, your indicator is on the canvas.
- You edit the code in the IDE.
- You hit Build (or
gradle buildin the console). - Velitask restarts and loads the new version of the plugin.
If Velitask isn't running or the Dev API is off, the task simply places the JAR and the request is skipped; the build won't fail. The new version is picked up the next time the application starts.
A restart closes the application the same way as a regular exit. If the application can't restart by itself, it tells you so — then close it and open it again manually.
Next: Next steps.