Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tcawley/gradle-protobuf-plugin
Gradle plugin for using Google Protocol Buffers in your project.
https://github.com/tcawley/gradle-protobuf-plugin
Last synced: about 2 months ago
JSON representation
Gradle plugin for using Google Protocol Buffers in your project.
- Host: GitHub
- URL: https://github.com/tcawley/gradle-protobuf-plugin
- Owner: tcawley
- License: mit
- Created: 2013-01-06T19:43:06.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-05-11T18:46:11.000Z (over 10 years ago)
- Last Synced: 2024-08-04T03:02:43.838Z (5 months ago)
- Language: Groovy
- Size: 435 KB
- Stars: 12
- Watchers: 2
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gradle - gradle-protobuf-plugin - Compile [Google Protocol Buffers](https://developers.google.com/protocol-buffers/) files. (Plugins / Code generation)
README
gradle-protobuf-plugin
======================[Gradle](http://gradle.org) plugin for using [Google Protocol Buffers](https://developers.google.com/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. Pythonlang {
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'
}