Giter Club home page Giter Club logo

Comments (9)

novabyte avatar novabyte commented on June 23, 2024

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.

aantono avatar aantono commented on June 23, 2024

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.

novabyte avatar novabyte commented on June 23, 2024

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.

novabyte avatar novabyte commented on June 23, 2024

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.

aantono avatar aantono commented on June 23, 2024

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.

novabyte avatar novabyte commented on June 23, 2024

Hey Alex,

Thanks for the feature enhancement, that works for me! :)

Cheers,

Chris

from gradle-plugin-protobuf.

tinhkyaw avatar tinhkyaw commented on June 23, 2024

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.

aantono avatar aantono commented on June 23, 2024

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.

tinhkyaw avatar tinhkyaw commented on June 23, 2024

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)

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.