-
Notifications
You must be signed in to change notification settings - Fork 274
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
Should deprecate usage of configuring generated file directory #332
Comments
Nit: Users may want a Copy task instead. Sync task wipes out the destination before copying. |
I don't think that configurability is actually the problem - I think the internal plugin logic should be able to handle it just fine - it should just run a delete on the target directory before it invokes the code generation. Note: I've run into this issue and worked around it by hacking in a manual delete. See #331 (comment) |
We know some users were dumping the generated code into directories containing other things. We don't want to go around deleting directories that we didn't create. |
Ah - okay. That seems like it's abusing the nature of the gradle build system / caching - but it's also not ideal to make a change that would delete unsuspecting users' files. Maybe the best way to go about it is to force the user to specify if they want the output directory deleted only if they have changed the default output directory. So:
would cause a build error with a helpful message. The correct configuration would be:
|
This raises an issue: If the user does not specify |
IMO, having no default and throwing an error when Edit: 3) If a new user uses the default configurations (w/ default |
After offline discussion with @zhangkun83, we think we should keep If users want to add some extra files into compilation, they can already do that with Is there any specific reason/use case you want to change the default |
I don't have any particular use-case for changing |
Likely will be able to fix #180 after fixing this issue. |
That's the user's fault and they simply shouldn't do this. Please don't take away configurability just "because people might abuse it". Pretty much every Gradle task allows configuring its output folder and those tasks also delete their output (with a few exceptions like the Copy task). The few users who set the output folder to something that shouldn't be deleted will notice this once, do a git reset and then change their build. No big deal. Configurability is important because you don't know how this plugin might be integrated into others. For example, the Java plugin and Android plugin each use very different folder structures. I'm sure there are more layouts out there, e.g. for Javascript projects etc. The protobuf plugin should not prescribe how they set up their output structure. |
Just solve the caching problem. In retrospect this is very hard due to limitations of protoc. |
As far as I understand there's basically kind of an agreement that it's fine to dump the outdir to solve the caching issue. Any chance for this to get out in one of the next builds? We just stumbled about it ourselves and now use a custom build, applying #347 to solve the issue, which really cost us quite some time for multiple developers already, which weren't aware of this plugin's behavior with keeping outdated generated files behind after switching branches. |
IMO: The user is not interested in where the generated files are. If everything compiles, that's all the user needs. For kotlin/java we can easily remove Open questions:
My plan is, two PRs.
|
We've seen a surprising number of people using the plugin for other languages. I think they mainly do Java or the like, but still interact with other languages so having everything in one build system is convenient. |
Directories are valid outputs for
You will have to read the output files, in a language appropriate way, to know which were generated by
Only knowable by parsing the output files in the destination directory. Ultimately |
We should use different output directories for different gradle tasks. If more than one gradle task write to one directory we will have overlapping outputs, as result If we have different output directories, we can easily check the input and output of the task if they have changed - just run to generate new code. Gradle provides a great API for this. |
This is a good idea, but I am not sure how to prevent the user from choosing a directory with pre-existing files. It seems appealing to let users still specify the directory, because it is really high value to let the project check in generated files. Imagine something like jitpack running on arm and there's a missing protoc artifact - you'd be trading one pain for another. |
How about to make it configurable it two modes: At least for us this would be a feasible way to go and get this issue which has been bothering us for the pasts months resolved. |
Fixes google#33 for users not changing generatedFilesBaseDir. Stop documenting generatedFilesBaseDir since it produces poor results, but keep it functional with its existing Copy semantics. Fixes google#332
Fixes #33 for users not changing generatedFilesBaseDir. Stop documenting generatedFilesBaseDir since it produces poor results, but keep it functional with its existing Copy semantics. Fixes #332 This deprecates the setter, but I don't know how to make this trigger a warning, for either Groovy and Kotlin. Both seem to ignore it. Turn off UnnecessaryObjectReferences because it isn't providing value.
Allowing configuring output directory for generated files is problematic, as it makes managing generated files harder.
Each run of
generateProtoTask
should always produce the just-right set of generated files for the given proto files. That is, unwanted files in generated files directory from previous build should be deleted (see #331 ).However, if we allow configuring output directory for generated files, we cannot easily wipe out the output directory before running
generateProtoTask
. So this usage should be deprecated. We would either ask users to do aSync
/Copy
task to bring generated files to their desired directory or we may support that by adding aCopy
task to do so for users.The text was updated successfully, but these errors were encountered: