Proto Js Plugin
The Gradle plugin which performs additional code generation for Protobuf types.
To run the plugin, add the "io.spine.tools:spine-proto-js-plugin:$spineBaseVersion"
to the classpath
configuration and add apply plugin: 'io.spine.tools.proto-js-plugin'
to the module generating JS messages.
In particular, the plugin:
- Generates a getter to obtain a
TypeUrl
for each type. - Generates parsers for types with standard JSON mapping.
- Exposes all the messages and enums as well as generated parsers (to be used by the Spine Web).
The main plugin action may be retrieved and configured as necessary via the "protoJs" extension. By default, the action is a dependency of the build task.
This plugin currently relies on the set of the hard-coded Gradle settings which have to be set to the required values in a project willing to use the plugin. These settings are:
- CommonJS import style for all generated code:
js {option "import_style=commonjs"}
;
The build.gradle
file located under the test/resources
folder of this module can be used as an example of the required project configuration.