Maven configuration changes
First, we need to add the following 2 dependencies to our project. Obviously we need the vertx-service-proxy
APIs:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-service-proxy</artifactId>
</dependency>
We need the Vert.x code generation module as a compilation-time only dependency (hence the provided
scope):
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-codegen</artifactId>
<scope>provided</scope>
</dependency>
Next we have to tweak the maven-compiler-plugin
configuration to use code generation, which is done via a javac
annotation processor:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<useIncrementalCompilation>false</useIncrementalCompilation>
<annotationProcessors>
<annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
</annotationProcessors>
<generatedSourcesDirectory>${project.basedir}/src/main/generated</generatedSourcesDirectory>
<compilerArgs>
<arg>-AoutputDirectory=${project.basedir}/src/main</arg>
</compilerArgs>
</configuration>
</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:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>${project.basedir}/src/main/generated</directory>
</fileset>
</filesets>
</configuration>
</plugin>
Tip | The full documentation on Vert.x services is available at http://vertx.io/docs/vertx-service-proxy/java/ |