Gradle RADL Plugin - restful-api-description-language/RADL GitHub Wiki
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:
validateRadlvalidates RADL files against the schema and against additional guidelinesgenerateDocumentationFromRadltransform RADL files into HTML-based documentationradl2springgenerates Spring server code from RADL filesextractRadlFromCodegenerates 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:
docsDirThe sub-directory of the project build directory into which documentation is generated. Defaults todocs/rest.cssURLOne optional css URL to customize the documentation. Defaults to RADL's default css.extraClasspathAdditional classpath added to theclasspathproperty (see Extracting RADL from Java code).extraProcessorsSee theextra.processorsproperty in Extracting RADL from Java codeextraSourceDirSee theextra.sourceproperty in Extracting RADL from Java codeheaderThe header to use for generated files. Defaults toGenerated by RADL..keepArgumentsFileWhether to keep the arguments file generated when Extracting RADL from Java code. Defaults tofalse.packagePrefixThe prefix to use when generating Java packages. Defaults to the service name.preExtractA closure to execute before Extracting RADL from Java code.radlCoreVersionThe version of the core library to use.radlDirNameLocation of RADL files. Defaults tosrc/main/radl.scmThe source code management system to use. Defaults todefault. The only other valid value isp4for Perforce.serviceNameThe name of the service that the RADL files describe. Defaults to the project's name.skipClasspathWhether to skip adding a classpath at all (see Extracting RADL from Java code). Defaults tofalse.