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

feature request: generate into a zipfile for python? #478

Closed
ckchow opened this issue Mar 4, 2021 · 2 comments
Closed

feature request: generate into a zipfile for python? #478

ckchow opened this issue Mar 4, 2021 · 2 comments

Comments

@ckchow
Copy link

ckchow commented Mar 4, 2021

https://developers.google.com/protocol-buffers/docs/reference/python-generated#invocation

The default python plugin is able to generate code directly into a zipfile. It determines whether to do this by looking at the suffix of the output path (and if it sees a .zip, it assumes you want a zipped output). Could we add an option to the python plugin to support this behavior? I think currently the plugin makes all the output directories up to and including outputSubdir. So this behavior almost works without modification except at the last second it complains

<...>.zip: Is a directory

@voidzcy
Copy link
Collaborator

voidzcy commented Mar 5, 2021

Looks we only need to not create a directory for the leaf of the path given by outputSubDir if it ends with .jar or .zip, and things will be working out of the box. outputSubDir maps to the --builtin_out in protoc invocations.

@cilki
Copy link
Contributor

cilki commented Sep 17, 2021

This works great the first time I run the task, but all subsequent runs fail because the plugin makes the output zip itself a source directory:

Caused by: org.gradle.api.InvalidUserDataException: Source directory '.../build/generated-proto/main/cpp.zip' is not a directory.
	at org.gradle.api.internal.file.DefaultSourceDirectorySet.getSourceTrees(DefaultSourceDirectorySet.java:273)
	at org.gradle.api.internal.file.DefaultSourceDirectorySet.getSrcDirTrees(DefaultSourceDirectorySet.java:256)
	at org.gradle.api.internal.file.DefaultSourceDirectorySet.getSrcDirs(DefaultSourceDirectorySet.java:114)
...

Any way to avoid creating a new source directory or maybe just remove it before the task runs?

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

No branches or pull requests

3 participants