I have written a code generator for my company, that basically has the following workflow:                 entity xml definition                           |                         v   gets validated and put into java runtime classes by jaxb                         |                         vruntime classes are written to .java files with stringtemplateNow it is possible to start a server and use those files. So far, so good.Before we can install the server for our customer, it needs to be validated for GAMP 5, which is a lot of work. Every time there is a change to the system, we have to test EVERYTHING from scratch, if we cannot make sure, that it has not changed.Therefore, I need to have a concept on how to version the generated code.The problem (1) is, that the generated code is neither commited to git, nor to SVN; only the xml definitions are put into SVN.Another thing (2) is, that the once the gradle task to generate the code, which is necessary as soon as something changed to the xml files, (currently) re-generates ALL .java files, even if there was no change to the xml file of the respective entity.The third (3) thing to have in mind is, an entity can be extended by another xml file. the workflow for this would look like                 entity xml definition  extension xml definition                         |                         |                         v                         v   gets validated and put into java runtime classes by jaxb                         \                        /                          \                      /                     Merging the runtime classes together                                     |                                     v      runtime classes are written to .java files with stringtemplateAn Ideawas to generate the .java file, and before overwriting old files, read them, and only overwrite them, if they differ. The output message would then say, which parts of the software needs to be re-validatedAnother approach would include generating hashcode for all the files and see if those differ from previous hashes.What would be the best way to do so?
How to version generated code without checking them into VC?
versioning;code generation
It is generally considered a bad idea to version-control generated files. The problem is that you most likely already have the generating files stored in the version control system. Then you have essentially the same information twice. Also, somebody can accidentally forget to update the generated files after updating the generating files.Have you considered an intelligent build system that automatically generates the generated files? If your tools always modify the timestamp of all generated files despite the fact that they may not be changed, the solution is to compare the contents of the new files with the contents of the old files, and updating them if they differ. Don't just use hash code, it's way too risky. Hash codes are meant for hash tables and there will be collisions in this case. Instead, use a secure hash such as SHA256 (SHA1 is already broken, and MD5 has been broken for a long time). Or you can do full file comparison instead of secure hash.Or, you can update your tools instead of doing the hacks to prevent modification in your build system.Anyway, since you're using Java, the compilation will be fast even if everything needs to be recompiled. My current project uses C and full compilation takes minutes (a ten-liner C file containing few #includes can end up being parsed as a ten-thousand-liner C file...).