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
|
v
runtime classes are written to .java files with stringtemplate
Now 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 stringtemplate
An Idea
was 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-validated
Another 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?
generated/
subdirectory, and you'll put files there only when their content has changed. I do that in GCC MELT