In this guide we'll show you how to develop a Vert.x project using Maven.
Vert.x provides a Maven Archetype that can generate an example Vert.x Maven project for you. You can then edit and adapt that project to develop your Vert.x module.
To generate a project type the following at the command line, in your project's root directory:
mvn archetype:generate -Dfilter=io.vertx:
This will search for any artifacts with group id
io.vertx and interactively prompt you as to which one you want.
You'll also be prompted for:
groupId. This is the
groupIdfor the module that we're going to generate, e.g.
artifactId. This the
artifactIdfor the module that we're going to generate, e.g.
version. This is the
versionfor the module that we're going to generate, e.g.
If you prefer you can specify these parameters on the command line, for example:
mvn archetype:generate -Dfilter=io.vertx: -DgroupId=com.mycompany -DartifactId=my-module -Dversion=0.1
A directory with a name corresponding to
artifactId will be created for you, with the example project in it. Let's go into it:
It's a functioning Maven project which creates a working Vert.x module. So you can do all the normal Maven stuff, for example, try:
This builds, tests and installs the module in your local Maven repository, where it can be picked up by other Vert.x modules or projects.
The outputs of the project are:
The outputs are created in the
target directory as per normal.
You configure several things as properties in
module.name determines the name of the module as described in the modules manual
vertx.pullInDeps determines whether all module dependencies should be packaged into the module as nested modules.
It also contains various properties used to configure versions of various dependencies.
If you want to override any Vert.x platform configuration, e.g.
cluster.xml or logging configuration, you can add those files to the directory
src/main/platform_lib - these will then be added to the Vert.x platform classpath when you run the module with
To run the integration tests
You can use the
eclipse goals to create IDE projects from your Maven project, for example
Once the IDE files have been created you can open the project in your IDE.
If your project needs a third party jar to build and you want to include it in the
lib directory of your module you can add the dependency in the
dependencies section of
pom.xml with a scope of
If you don't want it to be included in the
lib directory you should add it as
Once you've changed your dependencies just run
mvn idea:idea or
mvn eclipse:eclipse again to update your IDE project files with the new dependencies.
mvn deploy as normal to push your module to a Maven repository.
If you've pushed your module to a public Maven or Bintray repository you can register it in the Module Registry so others can search for and discover it.
Now you've got the project all set-up and running, it's time to explore the standard project layout itself.