generator
Plugin that generates mappings for Google APIs.
Usage
The plugin can be included via the plugins DSL:
plugins {
id("io.github.edricchan03.koogle-api.generator") version "<x.y.z>"
}Configuring the plugin
The plugin can be configured via the koogleApiGenerator top-level accessor in modules that use the generator as a plugin.
For more information on what properties are supported, see KoogleApiGeneratorPluginExtension.
Their default values are defined in Defaults.
Example
import io.github.edricchan03.koogle_api.plugin.generator.tasks.SchemaFileNameMapper
import java.net.URI
plugins {
id("io.github.edricchan03.koogle-api.generator") version "<x.y.z>"
}
koogleApiGenerator {
// The discovery URL to use.
// This property can also be set via the discoveryUrl() method, which takes
// a String.
discoveryUrl = URI("https://example.com")
discoveryUrl("https://example.com")
// Alternatively, a file/path can be used.
discoveryUrl(project.layout.buildDirectory.file("example.json"))
// The file to save the downloaded root discovery URL to.
// If not specified, this defaults to <project>/build/koogle-api-disc-docs/index.json
rootDiscoveryDocOutputFile = project.layout.buildDirectory.file("docs/discovery.json")
// The directory to save all discovery URLs to.
// If not specified, this defaults to <projects>/build/koogle-api-disc-docs
discoveryDocsOutputDir = project.layout.buildDirectory.dir("docs")
// Mapping function used to generate the output file name based from the specified
// DirectoryItem.
// If not specified, this defaults to
// `SchemaFileNameMapper { "${it.id.replace(":", "-")}.json" }`
// This property can also be set via the outputFileNameMapper() method, which takes
// the same argument but allows for trailing lambda syntax.
outputFileNameMapper = SchemaFileNameMapper { "${it.id.replace(":", "-")}.json" }
outputFileNameMapper { "${it.id.replace(":", "-")}.json" }
}Plugin tasks
The plugin exposes the following Gradle tasks:
| Name | Description | Implementation |
|---|---|---|
downloadRootDiscovery | Downloads the root Google API discovery document and saves it to disk | DownloadRootDiscoveryTask |
downloadDiscoveries | Downloads all Google API discovery documents from the root document and saves them to disk | DownloadDiscoveriesTask |
generateMappings | Generates a Gradle project from the specified Google API discovery document | GenerateMappingsTask |
Packages
Global package where common code such as KoogleApiGeneratorPlugin and KoogleApiGeneratorPluginExtension can be found.
Data classes used to represent a JSON schema.
Custom Kotlinx.serialization serializers for use. Currently, the following serializers are available:
Contains Gradle tasks which can be manually used in your own code if needed.
Contains classes that use Gradle's Worker API to develop parallel tasks.