• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

andrewkroh/gradle-protobuf-plugin: Gradle plugin for Google Protocol Buffers

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

andrewkroh/gradle-protobuf-plugin

开源软件地址(OpenSource Url):

https://github.com/andrewkroh/gradle-protobuf-plugin

开源编程语言(OpenSource Language):

Groovy 98.0%

开源软件介绍(OpenSource Introduction):

Gradle Protobuf Plugin

  • Author: Andrew Kroh
  • Download: See maven central
  • License: Apache License, Version 2.0
  • Requirements: Java 1.5+
  • Google Protocol Buffer Compiler (protoc): Any version

What is it?

This is a plugin for Gradle that enables compiling Google Protocol Buffer .proto files into data access classes. It generates Java, CPP, and Python source files from the .proto files in src/main/proto.

This plugin adds a dependency on the Java plugin so that it can compile the generated Java source files.

This plugin generates a sources jar that contains all of the Java sources (including those generated from the .proto files) in this project.

The Protocol Buffer compiler must be on the path for the plugin to work. If the protocol buffer is in a different location then specify the full path to the compiler in your build.gradle file using protobuf.compiler = '/full/path/protoc'.

Usage

apply plugin: 'protobuf'

The plugin JAR needs to be defined in the classpath of your build script. It is available from maven central.

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.andrewkroh.gradle:gradle-protobuf-plugin:0.5.0'
    }
}

The plugin automatically adds a dependency on the google protobuf jars so all you need to do is specify what repository(s) to use.

repositories {
    mavenCentral()
}

Project Layout

Simply put your .proto files in src/main/proto.

Tasks

The protobuf plugin defines the following task:

  • compileProto - Generates source files by compiling .proto files.

Extensions

The protobuf plugin adds a protobuf extension to the project which allows you to override the default configuration of the plugin.

  • version - Protocol Buffers version that your project requires. By specifying this value the plugin will verify that it is using specified version of the compiler.
  • src - Source directory for your .proto files. The value is relative to the project root.
  • compiler - Name (or full path) of the Google Protocol Buffer compiler that the plugin will execute.
  • outputCpp - Output directory for generated CPP source files. The value is relative to the project build directory.
  • outputJava - Output directory for generated java source files. The value is relative to the project build directory.
  • outputPython - Output directory for generated python source files. The value is relative to the project build directory.
  • outputToProjectDir - Output generated files relative to project root directory instead of relative to build directory. Defaults to false.
  • autoDependency - Activate or deactivate automatic dependency creation. If true, a compile time dependency on com.google.protobuf:protobuf-java is added automatically based on the Protocol Buffers version number. Defaults to true.

Example

See the example directory in this repository.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap