Preparing the Generated Code
The first step is to modify the code generation configuration in the gene-model/gene-model-dom/build.gradle file:
modelGeneration {
jdlFile = parent.file("spec/entities.jdl")
javaPackage = "com.example.caplan"
useCustomCode = true
}
sourceSets.main.java.srcDir "src/dom/java"
Above:
-
useCustomCodespecifies that the generated classes may contain custom code. When set totrue, the code generator will keep the custom code of the DOM classes when classes are re-generated. -
sourceSets.main.java.srcDirmust be modified to use the new generated code directorysrc/dom/javaby default instead of${buildDir}/generated/src/main/java.
The project is now configured to allow customization of the generated code.