If you use Vert.x with IntelliJ, you may have found yourself frequently running jps
and taskkill
to clear out all of the extraneous io.vertx.core.Launcher
processes. I do this every time I re-run my projects—seriously, is it just me?
But I may have just come up with a solution!
If you’re using Gradle, add this new task to your build.gradle
file:
1 2 3 4 5 6 7 8 9 |
task killLaunchers { def sout = new StringBuilder(), serr = new StringBuilder() def proc = 'cmd /c for /f "tokens=1" %i in (\'jps -m ^| find "Launcher"\') do ( taskkill /F /PID %i )'.execute() proc.consumeProcessOutput(sout, serr) proc.waitForOrKill(1000) println "out> $sout" println "err> $serr" println "done" } |
Next, edit your run configuration and, in the “Before launch” section, add “Run Gradle task” with your new task before “Build”. Also check the “single instance only” option.
Now anytime you run your project, it will first make sure all those pesky Launchers are gone!