Bootstrapping a Maven project
This guide makes the choice of using Apache Maven as the build tool, primarily because it is very well integrated with the major integrated development environments. You can equally use another build tool such as Gradle.
The Vert.x community offers a template project structure from https://github.com/vert-x3/vertx-maven-starter that can be cloned. Since you will likely want to use (Git) version control as well, the fastest route is to clone the repository, delete its .git/
folder and then create a new Git repository:
- git clone https://github.com/vert-x3/vertx-maven-starter.git vertx-wiki
- cd vertx-wiki
- rm -rf .git
- git init
The project offers a sample verticle as well as a unit test. You can safely delete all .java
files beneath src/
to hack on the wiki, but before doing so you may test that the project builds and runs successfully:
- mvn package exec:java
You will notice that the Maven project pom.xml
does 2 interesting things:
it uses the Maven Shade Plugin to create a single Jar archive with all required dependencies, suffixed by
-fat.jar
, also called “a fat Jar”, andit uses the Exec Maven Plugin to provide the
exec:java
goal that in turns starts the application through the Vert.xio.vertx.core.Launcher
class. This is actually equivalent to running using thevertx
command-line tool that ships in the Vert.x distribution.
Finally, you will notice the presence of the redeploy.sh
and redeploy.bat
scripts that you can alternatively use for automatic compilation and redeployment upon code changes. Note that doing so requires ensuring that the VERTICLE
variable in these scripts matches the main verticle to be used.
Note | Alternatively, the Fabric8 project hosts a Vert.x Maven plugin. It has goals to initialize, build, package and run a Vert.x project. To generate a similar project as by cloning the Git starter repository:
|