Gradle Protoc Plugin

Gradle plugin for protoc, the code generator typically associated with Google's Protocol Buffers

Лицензия

Лицензия

Категории

Категории

Gradle Компиляция и сборка
Группа

Группа

co.tomlee.gradle.plugins
Идентификатор

Идентификатор

gradle-protoc-plugin
Последняя версия

Последняя версия

0.0.3
Дата

Дата

Тип

Тип

jar
Описание

Описание

Gradle Protoc Plugin
Gradle plugin for protoc, the code generator typically associated with Google's Protocol Buffers
Ссылка на сайт

Ссылка на сайт

http://github.com/thomaslee/gradle-protoc-plugin
Система контроля версий

Система контроля версий

http://github.com/thomaslee/gradle-protoc-plugin

Скачать gradle-protoc-plugin

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/co.tomlee.gradle.plugins/gradle-protoc-plugin/ -->
<dependency>
    <groupId>co.tomlee.gradle.plugins</groupId>
    <artifactId>gradle-protoc-plugin</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/co.tomlee.gradle.plugins/gradle-protoc-plugin/
implementation 'co.tomlee.gradle.plugins:gradle-protoc-plugin:0.0.3'
// https://jarcasting.com/artifacts/co.tomlee.gradle.plugins/gradle-protoc-plugin/
implementation ("co.tomlee.gradle.plugins:gradle-protoc-plugin:0.0.3")
'co.tomlee.gradle.plugins:gradle-protoc-plugin:jar:0.0.3'
<dependency org="co.tomlee.gradle.plugins" name="gradle-protoc-plugin" rev="0.0.3">
  <artifact name="gradle-protoc-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='co.tomlee.gradle.plugins', module='gradle-protoc-plugin', version='0.0.3')
)
libraryDependencies += "co.tomlee.gradle.plugins" % "gradle-protoc-plugin" % "0.0.3"
[co.tomlee.gradle.plugins/gradle-protoc-plugin "0.0.3"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.codehaus.groovy : groovy-all jar 1.8.0

Модули Проекта

Данный проект не имеет модулей.

gradle-protoc-plugin

Status

Beta

Overview

A Gradle plugin for protoc, the code generator behind Google's Protocol Buffers.

Most Gradle plugins out there don't seem to do a great job of external protoc plugins (e.g. my own rpckit). This particular Gradle plugin tries to make the interface to third party protoc language support & plugins just as easy as for built-in languages.

Usage

Minimal configuration

apply plugin: 'java'
apply plugin: 'protoc'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'co.tomlee.gradle.plugins:gradle-protoc-plugin:0.0.3'
    }
}

repositories {
    mavenCentral()
}

dependencies {
    //
    // Choose whatever version is appropriate here
    //
    compile 'com.google.protobuf:protobuf-java:2.5.0'
}

This will:

  • Create a compileProto task and hook it up as a dependency of compileJava
  • Configure compileProto to inspect src/main/proto and write out Java code to src/main/gen-java.
  • Add src/main/gen-java to sourceSets.main.java
  • Create a cleanProto task and hook it up as a dependency of clean

If you don't use apply plugin: "java", the compileProto task will be created but will not be configured to generate Java code by default.

If protoc is not on your PATH

This is only necessary if you want to use a protoc binary that is not on your PATH:

protoc {
    executable "/usr/bin/protoc"
}

Modifying the protoc include path

protoc {
    path "path/to/protofiles"
    path "path/to/more/protofiles"
}

Using protoc plugins

protoc version 2.3.0+ supports plugins, which is neat:

compileProto {
    plugins {
        //
        // External protoc plugins are supported too
        //
        some_external_plugin {
            //
            // Optional if the plugin is on your $PATH and looks like `protoc-gen-<name>`
            //
            executable "/usr/local/bin/some-external-protoc-plugin"

            out destinationDir

            //
            // Options will be passed through to the protoc plugin on the command line.
            // Option values will be coerced to strings for the command line.
            //
            option foo: true
            option bar: 123
            option baz: "boz"
        }
    }
}

Defining your own ProtobufCompile tasks

ext.destination = file("build/gen-proto")

sourceSets.main.java.srcDir destination.path

task myProtoCompile(type: ProtobufCompile) {
    inputs.files fileTree("src/main/my-proto").include("**/*.proto")

    plugins {
        cpp {
            out destination
        }
        python {
            out destination
        }
    }
}

License

MIT

Support

Please log defects and feature requests using the issue tracker on github.

About

gradle-protoc-plugin was written by Tom Lee.

Follow me on Twitter or LinkedIn.

Версии библиотеки

Версия
0.0.3
0.0.2
0.0.1