Feature request: Support overwrite-only-changed
Created by: wheezil
Description
When using code-generators in an incremental build, it is time-consuming to have the generator touch all output files and cascade into build dependencies, even if nothing has changed. While one can usually make build systems only generate code when the input specification has changed, it is not always possible (for example, Visual Studio lacks a decent "generated sources" dependency mechanism). Even when the dependency chain works, it would be nice to only update the changed files, so that e.g. changing one field in a module doesn't cause everything to rebuild.
openapi-generator version
3.3.0
OpenAPI declaration file content or url
N/A
Command line used for generation
Currently using a custom generator of our own development. However I believe the problem/solution to cut across all generators.
Steps to reproduce
Run any code-generation. Note output file timestamps. Run it again. Note output file timestamps have all changed.
Related issues/PRs
None that I know of.
Suggest a fix/enhancement
Add a command-line option --minimal-update
to turn on this new behavior. When this option is specified, the generator will write a temporary file, compare its contents to the existing file, and if they differ, overwrite the existing file. It is possible to use hash-based conditions, but that probably adds complexity without any concrete benefit.