Skip to content
Rémon (Ray) Sinnema edited this page Nov 18, 2015 · 1 revision

Using the RADL Gradle Plugin

The RADL Gradle plugin is available from Bintray's jCenter:

buildSrc {
  repositories {
    jcenter { 
      url 'https://dl.bintray.com/radl/RADL/'
    }
  }
  dependencies {
    classpath "radl:radl-gradle:$radlGradleVersion"
  }
}

You can either hard-code the version of the plugin, or follow the above example an add a property to gradle.properties:

radlGradleVersion = 1.0.10

With that in place, you can add the plugin to your build file:

apply plugin: 'radl-gradle'

Gradle Tasks

The plugin adds the following tasks to your build:

  • validateRadl validates RADL files against the schema and against additional guidelines
  • generateDocumentationFromRadl transform RADL files into HTML-based documentation
  • radl2spring generates Spring server code from RADL files
  • extractRadlFromCode generates or updates a RADL file from Java code

See the following sections for more detail.

Validating RADL Descriptions

See Validating RADL Descriptions for an overview of the process. The validateRadl task is automatically added as a dependency of the check task.

Generating Documentation

See Generating Documentation for an overview of the process. The generateDocumentationFromRadl task is automatically added as a dependency of the assemble task. This task depends on the validateRadl task.

Generating Java Code

See Generating Java Code From RADL for an overview of the process. This task is available for use, but not added to any dependency by default.

Extracting RADL From Java Code

See Extracting RADL from Java code for an overview of the process. This task is available for use, but not added to any dependency by default.

Configuration

The plugin adds the radl project extension to your Gradle project with the following properties:

  • docsDir The sub-directory of the project build directory into which documentation is generated. Defaults to docs/rest.
  • cssURL One optional css URL to customize the documentation. Defaults to RADL's default css.
  • extraClasspath Additional classpath added to the classpath property (see Extracting RADL from Java code).
  • extraProcessors See the extra.processors property in Extracting RADL from Java code
  • extraSourceDir See the extra.source property in Extracting RADL from Java code
  • header The header to use for generated files. Defaults to Generated by RADL..
  • keepArgumentsFile Whether to keep the arguments file generated when Extracting RADL from Java code. Defaults to false.
  • packagePrefix The prefix to use when generating Java packages. Defaults to the service name.
  • preExtract A closure to execute before Extracting RADL from Java code.
  • radlCoreVersion The version of the core library to use.
  • radlDirName Location of RADL files. Defaults to src/main/radl.
  • scm The source code management system to use. Defaults to default. The only other valid value is p4 for Perforce.
  • serviceName The name of the service that the RADL files describe. Defaults to the project's name.
  • skipClasspath Whether to skip adding a classpath at all (see Extracting RADL from Java code). Defaults to false.