Copyright © 2011 Skyway Software
Table of Contents
MyEclipse for Spring has a mechanism for customizing all the templates that are used for code generation. This gives MyEclipse for Spring users a lot of flexibility in adapting the code generation capabilities according to their project requirements and standards. The customizations created with MyEclipse for Spring can also be shared with other developers. Sharing customizations is beneficial in a couple scenarios. First, this allows projects to set coding standards across developers and projects. Generation now becomes unique to the business and project requirements. Second, sharing customizations allows the expansion of features through a community of developers. For example, if someone wanted to add pagination to the Spring MVC User Interface, they could update the templates and share these customizations with others.
This tutorial will walk you through sharing the customizations created with the Customize Code Generation capability in MyEclipse for Spring.
The goal of this tutorial is to provide a quick step by step document that shows:
creating a customization project
packaging the project into a jar
using the customization jar in another project
The prerequisites needed to complete this tutorial are:
Download MyEclipse for Spring 10.0
A basic understanding of MyEclipse Customization Projects. Take a look at the Customize Code Generation using JET Templates tutorial for more information.
In MyEclipse for Spring you can create a Customization Project for customizing a full set of code generation templates. The Customization Project is a standard Eclipse project that contains all of the available JET templates. By default the scaffolding functionality will use the standard templates that reside in the installed MyEclipse for Spring plugins, but the project can be easily configured to use one or more Customization Projects as the source for the templates.
From the Eclipse Wizard selection menu (File-->New-->Other), select the MyEclipse for Spring Customization Project wizard (under MyEclipse customization folder). Click Next.
From the MyEclipse for Spring Customization Project wizard, enter AcmeCustomizations as the project name. Click Finish.
The customization project is now ready to use. For more information on these projects and an example of customizing the templates, please see the Customize Code Generation using JET Templates tutorial. The next section assumes you have already created some customizations.
After creating customizations in the MyEclipse for Spring Customization Project, to share this project it will need to be exported into a JAR. The following steps describe this process
Right-click the AcmeCustomizations project, and choose Export...
Expand Java, and highlight JAR. Click Next.
On the JAR File Specification wizard panel, Select the export destination, giving the jar a name.
Click Next until you get to the JAR Manifest Specification wizard panel (4th panel). Choose the Use existing manifest from workspace radio button, and choose to the /AcmeCustomizations/META-INF/MANIFEST.MF file through the Browse button.
That is all that's required to package a customization project into a jar. The next step is to use that jar in another project.
Now that a new customization project has been packaged, the next step is to use that jar in another project. Feel free to use another instance of MyEclipse for Spring, or pass this jar onto another developer as you go through the following steps.
It's really just a matter of copy and paste. Feel free to copy the customization jar anywhere in the current workspace. This tutorial creates a new folder called customization in a new project, and copies and pastes the acmecustomizations.jar into that folder.
Next, associate the customization jar with the project (or workspace), by going to the Project (or Workspace) Preferences > MyEclipse > Customization, and adding the jar as seen in the following figure.
Click OK all the way through, and now you are ready to scaffold with the customizations.
Finally it's time to run CRUD scaffolding to see the effect of the custom templates. The steps for scaffolding is beyond the scope of this tutorial. (If you need help scaffolding, please see Additional Developer Resources).
This was a very brief example on how to package and share Customization Projects in MyEclipse for Spring. If you have any questions, please contact us using the MyEclipse for Spring forums (see Additional Developer Resources).
You may also want to try other tutorials which are available in the Eclipse help system and online (see Additional Developer Resources).
What was your experience with this tutorial? Share your experience with us by completing a very brief survey.
Thank you for you interest in MyEclipse for Spring. If you are interested in learning more, the following developer resources are available:
Reference - Eclipse Help (MyEclipse for Spring 10.0 --> MyEclipse for Spring Reference) or Education Materials (online)
Tutorials - Eclipse Help (MyEclipse for Spring 10.0 --> Tutorials) or Education Materials (online)
Screencasts - MyEclipse for Spring YouTube Channel (online)
Support Forums - MyEclipse for Spring Forums (online)
Blog - MyEclipse for Spring Posts (online)