Getting Started with Eclipse MicroProfile, Part 7: Helidon
Up next in our series comes an offering from, to me, a somewhat surprising source, Oracle, and that offering is Helidon. I first heard about in September 2018, and while it’s still pre-1.0, it looks extremely promising.
Like Hammock, Helidon projects are jar projects, so we need to set the package type appropriately, then import the Helidon dependencies:
There are a number of dependencies pulled in transitively, but that’s fine. We only have to manage the one. Unless I’ve missed something, you do need to code an entry point. It’s an extremely small class that doesn’t do anything special, so I hope I’ve either overlooked something, or it’s something that will be fixed as the project matures. At any rate, here it is:
It seems like a waste of time, but, as best as I can tell, it’s required at the moment. :) With that in place, we’re almost ready to run it. We can, of course, run directly from the IDE, but to run from the command line, we need a Maven plugin. Or two. The official docs show the maven-jar-plugin, but I’ve also thrown in the maven-capsule-plugin we saw from Hammock:
The maven-dependency-plugin copies all of the projects runtime dependencies to the configured directory, and the maven-jar-plugin builds a jar, specifying where to find the dependencies (in the lib directory next to the jar) and the main class to run. Using this plugin, we would run the project like this:
$ java -jar target/helidon-1.0-SNAPSHOT.jar
The libs directory MUST be in target or you will get a java.lang.NoClassDefFoundError and the project will fail to start. If you move the jar, you must move lib as well.
With the maven-capsule-plugin, it’s all self-contained: