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:
- 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
Projectmodel, that is linked to and mirrors perfectly eachProjectTypeit 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 theexpansionSettings.xmlfile. For eachProjectTypeit finds, it will also dynamically create the command-line interface so the--helpis also populated for every availableProjectType. - If defined, the default values from each
ProjectArgumentTypeandProjectFlagTypeare copied to theProjectArgumentandProjectFlagelements. - For each available
ProjectType, theProjectinstance that was created is handed of to each of theProjectDataResolverclasses defined for thatProjectType. 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/--outputcan be processed. Because of this,getOutputDirectory()in theInitializationContextwill returnnull. - 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/--outputargument, defaulting if not defined to the directory where the initializer was invoked. This sub-command contains all the command-line arguments for the specificProjectType, over which it iterates and if the arguments are supplied, it updates theProjectmodel with the supplied values. - Now that the command-line arguments have been processed, all
ProjectDataResolverclasses defined for theProjectTypeare called once again to refine theProjectmodel further. At this stage the output directory is known, sogetOutputDirectory()in theInitializationContextwill no longer returnnull. That value is often used to set the default of an argument likeartifactIdto the name of the output directory. - The initializer will check if the option
-y/--yes-to-allhas been set on command-line. If it has, step 7 and 8 are skipped entirely, if not it will start the interactive mode handling. - At this stage the initializer will invoke all
InteractiveModeHandlerclasses defined for theProjectType. These are intended to prompt the user with questions. AnInteractionProviderobject 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 theProject, 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 theProjectbeyond setting the arguments to values obtained from user-interaction. - The final step of the
Projectmodel refinement once again calls everyProjectDataResolverclass defined for theProjectType. This is a final opportunity to process the values, after the user has had the opportunity to input more data through the interactive mode. - With the entire
Projectmodel being finalized, the initializer will write this to a<project.name>.xmlfile, alongside anexpansionSettings.xmlfile 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 apom-initializer.xmlMaven file to run the expansion for theProject. Unless--exportis defined, the initializer will now invoke Maven to run the expansion on thisProjectmodel to perform the actual initialization.