vert.x - How to compile and use Kotlin code in runtime? -
i'm trying create kotlin vert.x language support module , need way compile kotlin files , load results classloader
. i've tried using kotlin-compiler
library , found k2jvmcompiler
class, seems support command-line-style arguments exec
method. there way compile kotlin file in runtime (possibly without having save , read .class
files) , load generated classes? (kind of groovy does.) if not, have useful compiler arguments suggestions or pretty advices?
this feels xy problem. want know how compile kotlin on fly can more use vert.x running kotlin source files instead of compiled code. recommended path vert.x usage create simple bit of code deploys verticle within compiled code.
in question, link language support says vert.x 2 in path "vertx.io/vertx2/language_support.html"; different how done in vert.x 3. think merging 2 thoughts one. first vert.x 3 wants run java/kotlin files source (it doesn't really; vert.x 2 thing moved away compiled languages), , second need custom language support (you don't).
you should try use vert.x 3 running compiled code. so, build classes , run own main()
deploys verticle programatically. code simple as:
import io.vertx.core.vertx fun main(args: array<string>) { val vertx = vertx.vertx() vertx.deployverticle(someverticleofmine()) }
alternatively, docs running , deploying command-line say:
vert.x compile java source file on fly before running it. useful prototyping verticles , great demos. no need set-up maven or gradle build first going!
and indeed prototyping , quick testing, , isn't faster letting ide same , running compiled classes. have debugging features of ide infinitely valuable.
for few helper libraries using kotlin vert.x, view these options:
- vert.x 3 module klutter - author, 1 of libraries
- vert.x 3 helpers kotlin - cy6ergn0m
- kovert, rest framework vert.x 3 - author, 1 of libraries
- vert.x nubes - not kotlin specific, makes vert.x-web friendlier jvm languages.
there full sample project of running vert.x + kovert (specifically start app class). can @ code of kovert own similar work of starting , running vert.x nicely, promises or wish. docs kovert have links code starting vertx , starting verticle use vert.x-web, more sample code can read. helps understand injekt (light-weight dependency registry), kovenant (promises library), , klutter configuration injection understand complete sample.
other quick note, vert.x has codegen support other languages, since can call of java version directly, not need support kotlin either.
Comments
Post a Comment