This maven plugin is a wrapper around the rdl binary tool. Projects may use this plugin to generate java source files from rdl files defined within the project. RDL is a formal language for defining restful resources.
The :generate
goal generates java code from a project's rdl files.
mvn rdl:generate
It is simply a wrapper around rdl generate java-model
and rdl generate java-server
.
<project>
<dependencies>
<dependency>
<groupId>com.yahoo.rdl</groupId>
<artifactId>rdl-java</artifactId>
<version>1.5.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.yahoo.rdl</groupId>
<artifactId>rdl-maven-plugin</artifactId>
<version>1.15.2</version>
<configuration>
<rdlDirectory>${project.build.resources[0].directory}/rdl</rdlDirectory>
<sourceEncoding>UTF-8</sourceEncoding>
</configuration>
<executions>
<execution>
<id>generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<commands>
<arguments>generate -o ${project.build.directory}/generated-sources/rdl java-model ${project.build.resources[0].directory}/rdl/com/yahoo/assets.rdl</arguments>
<arguments>generate -o ${project.build.directory}/generated-sources/rdl java-server ${project.build.resources[0].directory}/rdl/com/yahoo/assets.rdl</arguments>
</commands>
<!-- rawCommands is equivalent to commands; only one or the other should be necessary -->
<rawCommands>
<rawCommand>
<arguments>
<argument>generate</argument>
<argument>-o</argument>
<argument>${project.build.directory}/generated-sources/rdl</argument>
<argument>java-model</argument>
<argument>${project.build.resources[0].directory}/rdl/com/yahoo/assets.rdl</argument>
</arguments>
</rawCommand>
<rawCommand>
<arguments>
<argument>generate</argument>
<argument>-o</argument>
<argument>${project.build.directory}/generated-sources/rdl</argument>
<argument>java-server</argument>
<argument>${project.build.resources[0].directory}/rdl/com/yahoo/assets.rdl</argument>
</arguments>
</rawCommand>
</rawCommands>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>bintray-yahoo-maven</id>
<name>bintray-plugins</name>
<url>http://yahoo.bintray.com/maven</url>
</pluginRepository>
</pluginRepositories>
</project>
Code generated by the :generate-jax-rs-resources
goal will depend on rdl-java
and some server classes.
<project>
<dependencies>
<dependency>
<groupId>com.yahoo.rdl</groupId>
<artifactId>rdl-java</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.2.2.v20140723</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.22.1</version>
</dependency>
</dependencies>
</project>
See the integration test for a more complete example.
Specifies the folder where the *.rdl
files are in the project source tree. Default value is src/main/resources/rdl
.
Ignored if commands
or rawCommands
are defined.
Defaults to project.build.sourceEncoding
, or UTF-8 if project.build.sourceEncoding
is not defined. Should be set
to the character encoding of the rdl files.
Defaults to false. If set to true, then this plugin will do nothing. Useful in the context of a multi-module maven project, when you want to override the inheritance of rdl-maven-plugin.
Defaults to:
generate -o ${project.build.directory}/generated-sources/rdl java-model src/main/resources/rdl/path/to/spec.rdl
generate -o ${project.build.directory}/generated-sources/rdl java-server src/main/resources/rdl/path/to/spec.rdl
Specifies the arguments that will be passed to the rdl binary. commands
is split by maven-utils. Use rawCommands
instead if you need more precise control on the split.
mvn clean install
Integration tests are handled by the maven-invoker-plugin
. They can be run with
mvn -P run-its clean install
To debug the plugin while it is running in an integration test, assign debugging flags to invoker.mavenOpts
.
For instance,
mvn -P run-its clean install -Dinvoker.mavenOpts="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
Copyright 2016 Yahoo Inc.
Licensed under the terms of the Apache version 2.0 license. See LICENSE file for terms.