Auto Redeploy Vert.x in IntelliJ IDEA

I’m using IntelliJ for Java development and I found that I was confused with how re-deployments would work for Vert.x. It turned it was simple, but it took a while to figure out.

  • Maven
  • Vert.x 3
  • IntelliJ IDEA 2016

I set up the configuration of IntelliJ and the Vert.x Launcher so that when classes were modified, the app would redeploy. But it seemed to only work the first time.

Step 1 — activate redeploy for your Run Configuration

In the menu, click on Run and then Edit Configurations
Create an Application. See below for a line you can copy and paste.
run io.vertx.example.HelloWorldEmbedded --redeploy="target/classes/**/*.class" --launcher-class=io.vertx.core.Launcher

Note that “ — redeploy” points to our Java classes. (See the caption under the image). This is different than let’s say in Eclipse where you would redeploy based on changes in *.java files.

Step 2 — Create a mod.json file in src/main/resources

The contents of this file should be:

{
"main": "io.vertx.example.HelloWorldEmbedded",
"auto-redeploy": true
}

Step 3 — Make changes to code, then redeploy.

IntelliJ doesn’t automatically build (for good reasons) so you’ll need to do the following:

  1. Run app, then make code change
  2. Select Build -> Rebuild Project or just press Cmd-Fn-F9.
  3. You’ll see the text INFO: Redeploying! — you can now refresh the browser (assuming this is a web app)

Some people like to set up a macro that builds the project upon save. That’s up to you. See https://www.jetbrains.com/help/idea/recording-macros.html for more details.

To reproduce with the example I used, clone https://github.com/vert-x3/vertx-examples and build the maven-simplest example and open up the pom.xml in IntelliJ. Then follow Step 1 and Step 2 above.

)

Torbjørn Kristoffersen

Written by

Based in South Africa — https://github.com/tk512

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade