Skip to main content

Initialization Process

The initializer applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution. goes through various phases in order to create the Project model.

The steps as shown in the diagram are as follows:

  1. When starting, the initializer applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution. will create an instance of the Project model, that is linked to and mirrors perfectly each ProjectType it finds in the expansion resourcesExpansion Resource (ExpansionResource). A reusable resource bundle containing expanders and features that provide specific application capabilities, defined in the expansion settings and added to the classpath during expansion. listed in the expansionSettings.xml file. For each ProjectType it finds, it will also dynamically create the command-line interface so the --help is also populated for every available ProjectType.
  2. If defined, the default values from each ProjectArgumentType and ProjectFlagType are copied to the ProjectArgument and ProjectFlag elements.
  3. For each available ProjectType, the Project instance that was created is handed of to each of the ProjectDataResolver classes defined for that ProjectType. The class can then set some initial values dynamically if needed. At this stage the CLI processor has not yet been called, which means that the output directory has not yet been processed, as this is done only at the point when -o/--output can be processed. Because of this, getOutputDirectory() in the InitializationContext will return null.
  4. The command-line processor is invoked, which then selects the correct command-line interface (sub-command) for the requested ProjectType. The sub-command will first process the -o/--output argument, defaulting if not defined to the directory where the initializer was invoked. This sub-command contains all the command-line arguments for the specific ProjectType, over which it iterates and if the arguments are supplied, it updates the Project model with the supplied values.
  5. Now that the command-line arguments have been processed, all ProjectDataResolver classes defined for the ProjectType are called once again to refine the Project model further. At this stage the output directory is known, so getOutputDirectory() in the InitializationContext will no longer return null. That value is often used to set the default of an argument like artifactId to the name of the output directory.
  6. The initializer will check if the option -y/--yes-to-all has been set on command-line. If it has, step 7 and 8 are skipped entirely, if not it will start the interactive mode handling.
  7. At this stage the initializer will invoke all InteractiveModeHandler classes defined for the ProjectType. These are intended to prompt the user with questions. An InteractionProvider object is provided to communicate with the user at this stage. For each prompt it is possible to define a default value. These are typically set to the current value of an argument in the Project, so the user can accept that current value or override it with a new value of their own choosing. It is not intended for this stage to actually do any processing of the Project beyond setting the arguments to values obtained from user-interaction.
  8. The final step of the Project model refinement once again calls every ProjectDataResolver class defined for the ProjectType. This is a final opportunity to process the values, after the user has had the opportunity to input more data through the interactive mode.
  9. With the entire Project model being finalized, the initializer will write this to a <project.name>.xml file, alongside an expansionSettings.xml file with the output directory and expansion resourcesExpansion Resource (ExpansionResource). A reusable resource bundle containing expanders and features that provide specific application capabilities, defined in the expansion settings and added to the classpath during expansion., as well as a pom-initializer.xml Maven file to run the expansion for the Project. Unless --export is defined, the initializer will now invoke Maven to run the expansion on this Project model to perform the actual initialization.