About
This page is about Hot reload in Vert.x
On matching file changes, the process is stopped and the application is restarted.
Example
Launcher
java io.vertx.core.Launcher run org.acme.MyVerticle --redeploy="**/*.class" --launcher-class=io.vertx.core.Launcher -cp ...
Vertx command line
Live redeploy with the vertx command of:
- a verticle with the launcher
vertx run \
org.acme.verticle.MyMainVerticle \
--redeploy="src/**/*.java" \
--launcher-class=io.vertx.core.Launcher
- a Main
vertx run \
--redeploy="src/**/*.java" \
--launcher-class=org.acme.vertx.Main
Groovy:
vertx run MyVerticle.groovy --redeploy="**/*.groovy" --launcher-class=io.vertx.core.Launcher
vertx run MyVerticle.groovy --redeploy="**/*.groovy,**/*.rb" --launcher-class=io.vertx.core.Launcher
Gradle
Live reload of a Main class
- Gradle DSL
mainClassName = 'net.bytle.api.Main'
def watchForChange = 'src/main/java/net/**/*'
def doOnChange = './gradlew classes'
run {
args = ['run', "--redeploy=$watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$doOnChange"]
}
equivalent to
vertx run --redeploy=src/**/* --launcher-class=net.bytle.api.Main --on-redeploy="./gradlew classes"
- Kotling DSL
val runTowerTaskGroup = "runTower"
val runTowerHotReloadTask = "runTowerHotReload"
val vertxLauncher = "io.vertx.core.Launcher"
val watchForChange = "src/main/java/net/**/*"
val doOnChange = "../gradlew classes"
tasks.register<JavaExec>(runTowerHotReloadTask) {
group = runTowerTaskGroup
mainClass.set(vertxLauncher)
args = mutableListOf(
"run",
"--launcher-class=$towerLauncher",
"--redeploy=$watchForChange",
"--on-redeploy=$doOnChange",
com.example.MainVerticle
)
classpath = sourceSets["main"].runtimeClasspath
if (project.hasProperty("currentDirectory")) {
workingDir = File(currentDirectory)
}
//dependsOn(processResources)
}