About
How to create a fat jar that wraps the vert.x launcher or a custom launcher to be able to use its commands
Articles Related
Syntax
Once the launcher is wrapped, you can call its commands like that
java -jar myapp.jar command args
Example
For instance:
- the Run command (Default) and its arguments.
java -jar my-vertx-fat.jar run -cluster -conf myconf.json -cp path/to/dir/conf/cluster_xml
- the Start command
java -jar my-verticle-fat.jar start --vertx-id=my-app-name
- the Stop command
java -jar my-verticle-fat.jar stop my-app-name
- the list command
java -jar my-verticle-fat.jar list
Why ? because the below fat jar call
java -jar my-vertx-fat.jar
is equivalent to
java -cp my-vertx-app.jar io.vertx.core.Launcher com.myexample.MyMainVerticle
Configuration
Default command
- The launcher will execute the run command (default).
- The default command is used if the fat jar is launched without a command.
- You can configure the default command by setting the Main-Command MANIFEST entry.
Verticle
The verticle started (also known as the main verticle) should be defined in the Main-Verticle attributes of the manifest.
Build tool
Gradle
plugins {
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'java'
}
mainClassName = 'io.vertx.core.Launcher'
shadowJar {
manifest{
attributes 'Main-Verticle': 'com.myexample.MyMainVerticle'
attributes 'Main-Command': 'run'
}
mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
}