Maven configuration changes

First, we need to add the following 2 dependencies to our project. Obviously we need the vertx-service-proxy APIs:

  1. <dependency>
  2. <groupId>io.vertx</groupId>
  3. <artifactId>vertx-service-proxy</artifactId>
  4. </dependency>

We need the Vert.x code generation module as a compilation-time only dependency (hence the provided scope):

  1. <dependency>
  2. <groupId>io.vertx</groupId>
  3. <artifactId>vertx-codegen</artifactId>
  4. <scope>provided</scope>
  5. </dependency>

Next we have to tweak the maven-compiler-plugin configuration to use code generation, which is done via a javac annotation processor:

  1. <plugin>
  2. <artifactId>maven-compiler-plugin</artifactId>
  3. <version>3.5.1</version>
  4. <configuration>
  5. <source>1.8</source>
  6. <target>1.8</target>
  7. <useIncrementalCompilation>false</useIncrementalCompilation>
  8. <annotationProcessors>
  9. <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
  10. </annotationProcessors>
  11. <generatedSourcesDirectory>${project.basedir}/src/main/generated</generatedSourcesDirectory>
  12. <compilerArgs>
  13. <arg>-AoutputDirectory=${project.basedir}/src/main</arg>
  14. </compilerArgs>
  15. </configuration>
  16. </plugin>

Note that the generated code is put in src/main/generated, which some integrated development environments like IntelliJ IDEA will automatically pick up on the classpath.

It is also a good idea to update the maven-clean-plugin to remove those generated files:

  1. <plugin>
  2. <artifactId>maven-clean-plugin</artifactId>
  3. <version>3.0.0</version>
  4. <configuration>
  5. <filesets>
  6. <fileset>
  7. <directory>${project.basedir}/src/main/generated</directory>
  8. </fileset>
  9. </filesets>
  10. </configuration>
  11. </plugin>
Tip
The full documentation on Vert.x services is available at http://vertx.io/docs/vertx-service-proxy/java/