Generate a Package

Return to Introduction  Previous page  Next page

In addition to generating source code from single classes and groups of classes, you can also generate code from a package. This feature provides options to recursively generate child packages and automatically generate directory structures based on the package hierarchy. This enables you to generate a whole branch of your project model in one step.

Select the Project | Source Code Engineering | Generate Package Source Code menu option. Alternatively, right-click on a package from the Project Browser window and select the Code Engineering | Generate Source Code menu option. The Package Code Generation dialog displays.




Root Package

The name of the package to be generated.


Options that specify how existing files should be generated.

Auto Generate Files

Specifies whether Enterprise Architect should automatically generate file names and directories, based on the package hierarchy.

Root Directory

If Auto Generate Files is selected, displays the path under which the generated directory structures are created.

Retain Existing File Paths

If Auto Generate Files is selected, specifies whether to use existing file paths associated with classes. If unselected, Enterprise Architect generates classes to automatically determined paths, regardless of whether source files are already associated with classes.

Include all Child Packages

If selected, all classes from all sub-packages of the target package are included in the list. This option facilitates recursive generation of a given package and its sub-packages.

Select Objects to Generate

Lists all classes that are available for generation under the target packages. Only selected (highlighted) classes are generated. Classes are listed with their target source file.




Select All

Marks all classes in the list as selected.

Select None

Marks all classes in the list as unselected.


Starts the generation of all selected classes.


Exits the Generate Package Source Code dialog. No classes are generated.

Generate a Package

To generate a package, follow the steps below:

1.In the Project Browser window, right-click on the package to generate code for. The context menu displays.
2.Select the Code Engineering | Generate Source Code menu option. The Generate Package Source Code dialog displays.
3.In the Synchronize field, click on the drop-down arrow and select the appropriate synchronize option:
·Synchronize model and code: Classes with existing files are forward synchronized with that file; classes with no existing file are generated to the displayed target file
·Overwrite code: All selected target files are overwritten (forward generated)
·Do not generate: Only selected classes that do not have an existing file are generated; all other classes are ignored.
4.Highlight the classes to generate. Leave unselected any to not generate.
5.If you want Enterprise Architect to automatically generate directories and filenames based on the package hierarchy, select the Auto Generate Files checkbox. Enterprise Architect prompts you to select a root directory under which the source directories are to be generated. By default, the Auto Generate Files feature ignores any file paths that are already associated with a class. You can change this behavior by also selecting the Retain Existing File Paths checkbox.
6.To include all sub-packages in the output, select the Include Child Packages checkbox.
7.Click on the Generate button to start generating code.

As code generation proceeds Enterprise Architect displays progress messages. If a class requires an output filename Enterprise Architect prompts you to enter one at the appropriate time.