REST Builder Gradle Plugin

The REST Builder Gradle plugin lets you generate a REST layer defined in the REST Builder rest-config.yaml and rest-openapi.yaml files.

The plugin has been successfully tested with Gradle 4.10.2.

Usage

To use the plugin, include it in your build script:

buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins.rest.builder", version: "1.0.21"
    }

    repositories {
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}

apply plugin: "com.liferay.portal.tools.rest.builder"

The REST Builder plugin automatically applies the java plugin.

Since the plugin automatically resolves the Liferay REST Builder library as a dependency, you have to configure a repository that hosts the library and its transitive dependencies. The Liferay CDN repository hosts them all:

repositories {
    maven {
        url "https://repository-cdn.liferay.com/nexus/content/groups/public"
    }
}

Tasks

The plugin adds one task to your project:

NameDepends OnTypeDescription
buildREST-BuildRESTTaskRuns the Liferay REST Builder.

BuildRESTTask

Tasks of type BuildRESTTask extend JavaExec, so all its properties and methods, such as args and maxHeapSize are available. They also have the following properties set by default:

Property NameDefault Value
argsREST Builder command line arguments
classpathproject.configurations.restBuilder
main"com.liferay.portal.tools.rest.builder.RESTBuilder"
systemProperties[]

Task Properties

Property NameTypeDefault ValueDescription
copyrightFileFilenullThe file that contains the copyright header.
restConfigDirFile${project.projectDir}The directory that contains the rest-config.yaml and rest-openapi.yaml files.

In the typical scenario, the rest-config.yaml and rest-openapi.yaml files are contained in the project directory of my-rest-app-impl. In the build.gradle of the same module, apply the com.liferay.rest.builder plugin.

The properties of type File supports any type that can be resolved by project.file. Moreover, it is possible to use Closures and Callables as values for the String properties, to defer evaluation until task execution.

Additional Configuration

There are additional configurations added to use REST Builder.

Liferay REST Builder Dependency

By default, the plugin creates a configuration called restBuilder and adds a dependency to the latest released version of Liferay REST Builder.

dependencies {
    restBuilder group: "com.liferay", name: "com.liferay.portal.tools.rest.builder", version: "1.0.22"
}
« Node Gradle PluginService Builder Gradle Plugin »
Este artigo foi útil?
Utilizadores que acharam útil: 0 de 0