Skip to content

balthz/gradle-flatbuffers-plugin

 
 

Repository files navigation

gradle-flatbuffers-plugin

Build Status

Gradle plugin for generating code from Google FlatBuffers schemas.

Requirements

This plugin requires that the FlatBuffers compiler be installed on the system.

For information on building and installing the compiler please refer to the FlatBuffers Documentation.

Usage

Please see the Gradle Plugin Portal for instructions on including this plugin in your project.

Extension Properties

The plugin defines the following extension properties in the flatbuffers closure:

Property Type Default Value Required Description
flatcPath String flatc False The path to the flatc compiler.
language String null False The language to use when compiling the FlatBuffers.

Note: Please see the Supported Languages section for valid language values.

Custom Task Types

The plugin provides the following custom task types for generating FlatBuffers:

Type Description
FlatBuffers Compiles FlatBuffers schemas.

FlatBuffers

This task type compiles FlatBuffers schemas.

    task createFlatBuffers(type: FlatBuffers) {
        inputDir = file("src/main/flatbuffers")
        outputDir = file("src/generated/flatbuffers")
        language = 'java'
    }
Property Type Default Value Required Description
inputDir File src/main/flatbuffers False The path to the schemas directory.
outputDir File null True The path to the directory for compiled FlatBuffers.
language String value in extension False The language to use when compiling the schemas.

Note: Please see the Supported Languages section for valid language values.

Supported Languages

The plugin supports generating code in all languages currently supported by FlatBuffers:

Language Property Value
C++ cpp
Java java
C# csharp
Go go
Python python
Javascript javascript
PHP php
GRPC grpc

Example

This example generates Java FlatBuffers from the schema files in the default src/main/flatbuffers directory and places the generated code in src/generated/flatbuffers.

    import io.netifi.flatbuffers.plugin.tasks.FlatBuffers
    
    plugins {
      id "io.netifi.flatbuffers" version "1.0.3"
    }

    flatbuffers {
        flatcPath = '/Users/greg/bin/flatc'
        language = 'java'
    }
    
    task createFlatBuffers(type: FlatBuffers) {
        outputDir = file("src/generated/flatbuffers")
    }

Bugs and Feedback

For bugs, questions and discussions please use the Github Issues.

License

Copyright 2017 Netifi Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Gradle plugin for generating code from Google FlatBuffers schemas

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 100.0%