Comments (9)
For anyone that stumbles upon this issue. A suboptimal workaround that I'm using at the moment is as follows:
depedencies {
protobuf files("$buildDir/distributions/some_project_pb.zip")
}
task protobufZip(type: Zip) {
archiveName = 'some_project_pb.zip'
from "$projectDir/deps/some_project/src"
include '**/*.proto'
}
extractProto.dependsOn protobufZip
Essentially the above code introduces a task that runs before the extractProto
task which zips up the Protocol Buffer definition files in the git submodule dependency that I have on another project. The extractProto
task then unzips the files and the generateProto
task calls the protoc
compiler.
This code moves backwards to go forwards... by zipping up code so that it can then be unzipped by this plugin. If I get some time I'll work on submitting a pull request for this issue but I'm not likely to have time at all soon.
from gradle-plugin-protobuf.
Why not just put the files into your ${projectDir}/src/main/proto directory? The plugin will take all the *.proto files from there and run protoc against them.
from gradle-plugin-protobuf.
Well, let's say that I'm including (for example) this project as a submodule in my Git project:
https://github.com/basho/riak_pb
That project has three Protobuf definition files (at the moment, this could change at any moment...): riak.proto
, riak_kv.proto
and riak_search.proto
. The application I'm writing only cares about two of those files. I think it's reasonable to assume that it should be possible to at least do something like this in the dependency closure:
dependencies {
protobuf files('deps/riak_pb/src/riak.proto', 'deps/riak_pb/src/riak_kv.proto')
}
At the moment I'm actually using a modified version of the Zip task I pasted above to zip only the two files.
from gradle-plugin-protobuf.
Essentially what I'm hoping for is the inclusion of more fine-grained control over which Protobuf definition files are compiled to Java code without the need to Zip and Unzip a collection of .proto
files.
Let me know if the use case (motivation) for this feature request needs more discussion. Cheers.
from gradle-plugin-protobuf.
Chris, I've taken a stab at implementing the functionality you've described. Please let me know if this is how you wanted it to work.
Thanks,
Alex
from gradle-plugin-protobuf.
Hey Alex,
Thanks for the feature enhancement, that works for me! :)
Cheers,
Chris
from gradle-plugin-protobuf.
Hi Alex,
This is a very useful update. Can you please upload the jar to Maven Central as well?
Also, is there any plan to support wildcards (like *.proto) in the files definition?
Thank You,
Tin
from gradle-plugin-protobuf.
Hello Tin,
I am working on cutting the final release of the new version sometime by the end of this month. (Want to make sure that Issue 8 gets resolved). As for the wildcards, you can use any standard Gradle FileCollection generating function (such as files, fileTree, etc), so you should be able to use http://www.gradle.org/docs/current/javadoc/org/gradle/api/Project.html#fileTree(java.util.Map) with something like this: protobuf fileTree(dir: 'protos', include: '*.proto')
Here is the documentation reference - http://www.gradle.org/docs/current/userguide/dependency_management.html#sub:file_dependencies
from gradle-plugin-protobuf.
Thank you very much for the detailed response, Alex. I tried and it works for me now. Looking forward to your next release :-)..
from gradle-plugin-protobuf.
Related Issues (15)
- incompatible with the android plugin HOT 3
- Specify repository as a dependency HOT 3
- Update methods to be deprecated in Gradle 2.0 HOT 4
- How to generate output?
- Add support for the other built-in code generators HOT 1
- Adding directory to protoc's include path HOT 1
- Plugin should have an simpler name HOT 1
- Prevent copying protos to extractedProtosDir
- Plugin prints "error" message when running Gradle 2.1 HOT 1
- Don't compile protos in extracted-protos HOT 4
- protobufCodeGenPlugins strips everything after colon in Windows filenames
- Assumption of 'proto' subdir is too restrictive
- proto import statement from Android project to Android project broken? HOT 1
- Unable to build proto in generateProto task HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gradle-plugin-protobuf.