Preventing JHipster import-jdl from overwriting changes when updating entities

前端 未结 1 942
一向
一向 2020-12-21 03:32

With my current workflow I have to check in git and manually read changes like added functions after every import-jdl that touches an entitiy I changed.

Is there a w

相关标签:
1条回答
  • 2020-12-21 04:14

    I faced this problem in one of my projects and I'm afraid there is no easy way to tell JHipster not to overwrite your changes.

    The good news is you have two ways of mitigating this and both will make your life much easier.

    Update your entities in a separate branch

    The idea is to update your entities (execute the import-jdl command) in a different branch and then, once the whole process is finished merge the changes back to master.

    This requires no extra changes to your code. The problem I had with this approach is that sometimes the merges were not trivial and I still had to go through a lot of code just to be sure that everything was still in place and working properly.

    Do not change the generated code

    This is known as the side-by-side practice. The general idea is that you never change the generated code directly, instead you put your custom code in new files and extend the original ones whenever possible.

    This way you can update your entities and JHipster will never remove or modify your custom code.

    There are two videos available that will teach you (with examples) how to manage this:

    • Custom and Generated Code Side by Side by Antonio Goncalves
    • JHipster side-by-side in practice by David Steiman

    In my opinion this is the best approach.

    I know this probably isn't the answer you were looking for, but to my knowledge there's no better way.

    0 讨论(0)
提交回复
热议问题