Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please document how to generate Python sources #230

Closed
massenz opened this issue May 28, 2018 · 4 comments
Closed

Please document how to generate Python sources #230

massenz opened this issue May 28, 2018 · 4 comments

Comments

@massenz
Copy link
Contributor

massenz commented May 28, 2018

Reading #13, it states that setting this:

sourceSets {
  main {
    proto {
      builtins {
        python {
        }
      }
    }
  }
}

should generate python sources too; but I get an error:

A problem occurred evaluating root project 'ServerlessProtos'.
> Could not find method builtins() for arguments [build_7w3n39f0fdfgkgnm0to8jwh56$_run_closure6$_closure9$_closure10$_closure11@6ad993e4] on main Proto source of type com.google.protobuf.gradle.ProtobufSourceDirectorySet.

Be that as it may - this is, to say the least, non-intuitive.

How difficult would it be to have something like:

protobuf {
  ...
  generatePython = true
}

or something to that effect?

I am perfectly capable of creating a bash script to do both, but it would be nice to just run ./gradlew install and have both Java/Python generated.

Thanks!

@zhangkun83
Copy link
Collaborator

The syntax from #13 is outdated. With the latest version of the plugin, you don't specify output in the sourceSets, but in the generateProtoTasks block. The minimal code would be:

protobuf {
  generateProtoTasks {
    // all() returns the collection of all protoc tasks
    all().each { task ->
      task.builtins {
        remove java
        python { }
      }
    }
  }
}

@massenz
Copy link
Contributor Author

massenz commented May 30, 2018

Thanks.
This issue was, in fact, about actually documenting this (I was just pointing out that searching around for suggestions, that was all I could find).

Unless you tell me it's a bad idea, I'd like to add that info to this project's README and submit a PR: would that be ok?

@zhangkun83
Copy link
Collaborator

It is already documented. Try searching for "python" in the current README. Feel free to make a PR if you find anything that can be improved.

@massenz
Copy link
Contributor Author

massenz commented May 31, 2018

ah, yes, completely missed it, sorry!
I've pushed a PR to make it a bit more prominent, hope this helps: I'm obviously grateful for the plugin, saves the effort of messing around with bash and stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants