Giter Site home page Giter Site logo

playbar / gradle-protobuf-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewkroh/gradle-protobuf-plugin

0.0 1.0 0.0 387 KB

Gradle plugin for Google Protocol Buffers

License: Apache License 2.0

Protocol Buffer 1.98% Groovy 98.02%

gradle-protobuf-plugin's Introduction

Gradle Protobuf Plugin

  • Author: Andrew Kroh
  • Website: http://blog.crowbird.com
  • 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.

gradle-protobuf-plugin's People

Contributors

andrewkroh avatar jakewharton avatar trulsmag avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.