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 code from child Packages and automatically generate directory structures based on the Package hierarchy. This enables you to generate code for a whole branch of your project model in one step.

Access    Project Browser | Right-click on Package | Code Engineering | Generate Source Code

Generate code from a Package, on the Generate Package Source Code dialog

Step

Action

See also

1

In the Synchronize field, click on the drop-down arrow and select the appropriate synchronize option:

·Synchronize model and code: Code for Classes with existing files is forward synchronized with that file; code for Classes with no existing file is generated to the displayed target file
·Overwrite code: All selected target files are overwritten (forward generated)
·Do not generate: Generate code for only those selected Classes that do not have an existing file; all other Classes are ignored

 

 

2

Highlight the Classes for which to generate code; leave unselected any to not generate code for.

If you want to display more of the information within the layout, you can resize the dialog and its columns.

 

 

3

To make Enterprise Architect automatically generate directories and filenames based on the Package hierarchy, select the Auto Generate Files checkbox; this 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.

 

 

4

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

 

 

5

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 into which to generate code for the second partial Class.

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

Option

Action

See also

Root Package

Check the name of the Package for which code is to be generated.

 

 

Synchronize

Select options that specify how existing files should be regenerated.

 

 

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 Auto Generate Files is unselected, Enterprise Architect generates Class code to automatically determined paths, regardless of whether source files are already associated with the Classes.

 

 

Include all Child Packages

Also generate code for all Classes in all sub-Packages of the target Package in the list.

This option facilitates recursive generation of code for a given Package and its sub-Packages.

 

 

Select Objects to Generate

List all Classes that are available for code generation under the target Packages; only code for selected (highlighted) Classes is 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.

 

 

Generate

Start the generation of code for all selected Classes.

 

 

Cancel

Exit the Generate Package Source Code dialog; no Class code is generated.

 

 

Learning Center topics

·(Alt+F1) | Enterprise Architect | Software Engineering | Generate Code | Generate a Package