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:

  • useCustomCode specifies that the generated classes may contain custom code. When set to true, the code generator will keep the custom code of the DOM classes when classes are re-generated.

  • sourceSets.main.java.srcDir must be modified to use the new generated code directory src/dom/java by default instead of ${buildDir}/generated/src/main/java.

The project is now configured to allow customization of the generated code.