Git Product home page Git Product logo

gradle-protobuf-plugin's Introduction

gradle-protobuf-plugin

Gradle plugin for using Google Protocol Buffers in your Gradle project.

Quick Start

build.gradle

// Apply the plugin
buildscript {
    repositories {
        mavenCentral()
    }
    
    dependencies {
        classpath 'com.tomcawley:gradle-protobuf-plugin:0.2'
    }
}

apply plugin: 'gradleProtobufPlugin'

// Point to your protobuf library for compilation of the generated files
dependencies {
    compile "com.google.protobuf:protobuf-java:2.4.1"
}

// And finally the important stuff
protoBuf {
    protoc {
        'Mac OS X' {
            path = "/Users/user/Downloads/protobuf-2.4.1/src/protoc"
        }
    }
    
    // Optional, defaults to 'src/main/proto'
    sourceSets {
        proto {
            srcDir = 'src/main/proto'
        }
    }

    lang {
        java {
            genDir = 'src/main/java'
        }
        cpp {
            genDir = 'src/main/c++'
        }
    }
}

Features

Programming languages supported:

  1. Java

     lang {
         java
     }
    

    Compiles the .proto files into .java files (output to lang.java.genDir).

    Implies:

     apply plugin: 'java'
     compileJava.dependsOn compileProto
     clean.dependsOn cleanProto
    
  2. C++

     lang {
         cpp
     }
    

    .proto generation only at this time.

  3. Python

     lang {
         python
     }
    

    .proto generation only at this time.

Tasks

  • compileProto - Compiles the .proto files found in protoBuf.sourceSets.proto.srcDir for each programming language specified.
  • cleanProto - Deletes the generated files for each programming language compiled.

Conventions

  • protoc { ... }

    Platform dependent. Specify the name of your platform as determined by Java's System.getProperty("os.name");

path specifies the path to the protoc executable for your platform.

Examples:

    protoc {
        'Mac OS X' {
            path = '/path/to/protoc'
        }
        'Windows 7' {
            path = 'C:\\Path\\To\\protoc.exe'
        }
        `Windows XP' {
            path = 'C:\\Path\\To\\protoc.exe'
        }
    }
  • sourceSets { ... }

    Optional; if unspecified configures proto.srcDir=src/main/proto

      // Override
      sourceSets {
          proto {
              srcDir = '/where/you/want'
          }
      }
    

    Supports only local files. Remote folders coming soon (e.g., http://your/protos).

  • lang { ... }

    Configures the programming language(s) you want your .proto files compiled to. The default genDir is src/main/$name, where $name is the name of the programming language (e.g., java, cpp, python).

      // Override
      lang {
          java {
              genDir = 'src'
          }
      }
    

    Defaults:

      lang {
          java   // Defaults genDir to 'src/main/java'
          cpp    // Defaults genDir to 'src/main/cpp'
          python // Defaults genDir to 'src/main/python'
      }
    

gradle-protobuf-plugin's People

Contributors

tcawley avatar jakobwenzel avatar theomega avatar eshepelyuk avatar ramonwirsch avatar

Watchers

James Cloos avatar Guru Dharmateja Medasani 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.