Generate Code
From Taylor
Contents |
Generate Menu
Right-click on the model node and select Generate/All. This will run all of the generator templates.
Here are the projects that are created. The console shows what templates were executed.
Each template knows what project it should be generated into based on its specified project suffix. Each of these projects equates to a different Maven artifact and pom.xml file.
- master - The master maven project with all the common dependencies and used to build everything.
- jpa - All java code for the entity beans.
- ejb - All java code for the stateless session beans and message driven beans.
- jsf - All code for the user interface.
- web - The WAR project.
- app - The EAR project.
- doc - An optional project for generating the model documentation.
- wsclient - An optional project to house all the generated web service clients.
- qa - An optional project to house all the JSFUnit and Taylor Results test cases.
See Preferences below about controlling this behavior.
Classpath
Now lets setup the classpath before browsing the code.
Open the Eclipse preferences and add a M2_REPO classpath variable that points to your Maven repository ${user.home}/.m2/repository
- Or use maven: mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
Open a command window, navigate to your master project directory, and run mvn install and then mvn eclipse:eclipse to generate the .project and .classpath files for all of the projects.
NOTE: If this is the first time you are running this it will take a while to download all the necessary jars. You may have to repeat it several times.
- If you want to use WTP with the web project then use mvn eclipse:eclipse -Dwtpversion=1.5 in the web and pdf project directories
- JSF Support
Now, go back to Eclipse and switch to the Java perspective. Then select all the projects and press F5 to refresh.
Now browse the code to see what was generated. The high-lights are discussed below.
Regenerating
When regenerating exisiting files are handled in three ways:
- Java files are merged to preserve your modifications.
- Static Non-Java files, like pom.xml, components.xml, and application.xml, are skipped.
- Other Non-Java files like Facelets (*.xhtml) are backed up. You can then merge them with your SCM tools.
There are also other menus under Generate to allow you to run specific generator templates. All of these menus are context sensitive to the UML element you have selected. These are listed in the order which they are more often used.
- By Project Suffix
- Run all templates that will produce code in the chosen project
- By Template
- Run a specific template on the selected element(s)
- By Extension
- Run all templates for a type of source file
- By Plugin
- Run all templates from the chosen generator plug-in
- Clear Template Cache
- This is useful when you are customizing the templates
Preferences
Use the Preferences to turn generator plug-ins on or off and to change the target project name suffix.
- If you never want to run a particular generator plug-in then you can turn it off.
- You can also override the various project suffixes, if you would prefer a different name.
- When upgrading to a new version it is useful to set Ignore Skip to regenerate static files such as deployment descriptors.
- If you are using SCM then you can safely set Skip Backup.
Maven Stereotype
It is also possible to set preferences on a per model basic by applying the Maven stereotype to the model element.
The following attributes control the pom.xml generation:
- Group Id
- Parent Id
- Artifact Id
- Version
- Name
The following attributes control generation:
- Exclude Generators
- List of plug-in names
- Ignore Skip
- Suffix Overrides
- Right-click > New on model element
- Redirect generation to a different project
- Output Pattern Overrides
- Right-click > New on model element
- Redirect generation to a different directory
For example, taylor-audit combines the jpa and jsf projects into one by with 2 suffix overrides
- jpa > blank
- jsf > blank
(NOTE: literally blank, not the word)




