Please note : This help page is not for the latest version of Enterprise Architect. The latest help can be found here.

Generate a Package

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.

To generate a package, follow the steps below

How To:



See also


In the Project Browser, right-click on the package to generate code for. The context menu displays.



Select the Code Engineering | Generate Source Code menu option. The Generate Package Source Code dialog displays.



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



Highlight the Classes to generate. Leave unselected any to not generate. If you want to display the information in a more readable layout, you can resize the dialog and its columns.



To make Enterprise Architect automatically generate directories and filenames based on the package hierarchy, select the Auto Generate Files checkbox. This then enables the Root Directory field, in which you 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.



To include all sub-packages in the output, select the Include Child Packages checkbox.



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 (assuming Auto Generate Files is not selected). For example, if the selected Classes include partial Classes, a prompt displays to enter the filename for the second partial Class.

For additional information on the options on the Generate Package Source Code dialog, see the following table:



See also

Root Package

Check the name of the package to be generated.



Select options that specify how existing files should be generated.


Auto Generate Files

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


Root Directory

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


Retain Existing File Paths

If Auto Generate Files is selected, specify 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

Include all Classes from all sub-packages of the target package in the list. This option facilitates recursive generation of a given package and its sub-packages.


Select Objects to Generate

List 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

Mark all Classes in the list as selected.


Select None

Mark all Classes in the list as unselected.



Start the generation of all selected Classes.



Exit the Generate Package Source Code dialog. No Classes are generated.