MyEclipse Logo

MyEclipse for Spring 10.0: Package and Share Customized Code Generation

How to share the customizations you create

Niel Eyde

Skyway Software, Inc.

Table of Contents

1. Introduction
2. Goal
3. Prerequisites
4. Create MyEclipse for Spring Customization Project
5. Packaging the Customization Project
6. Use a customization jar in another project
7. Scaffold with customized templates
8. Conclusion
9. Additional Developer Resources

1. Introduction

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.

2. Goal

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

3. Prerequisites

The prerequisites needed to complete this tutorial are:

4. Create MyEclipse for Spring Customization Project

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.

  1. From the Eclipse Wizard selection menu (File-->New-->Other), select the MyEclipse for Spring Customization Project wizard (under MyEclipse customization folder). Click Next.

    Figure 1. Select Wizard: MyEclipse for Spring Customization Project


  2. From the MyEclipse for Spring Customization Project wizard, enter AcmeCustomizations as the project name. Click Finish.

    Figure 2. MyEclipse for Spring Customization Project Wizard


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.

5. Packaging the Customization Project

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

  1. Right-click the AcmeCustomizations project, and choose Export...

  2. Expand Java, and highlight JAR. Click Next.

    Figure 3. Select Export > Java > JAR


  3. On the JAR File Specification wizard panel, Select the export destination, giving the jar a name.

  4. 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.

    Figure 4. JAR Export - select manifest


  5. Click Finish.

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.

6. Use a customization 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.

  1. 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.

    Figure 5. Copy and Paste the customization jar into the workspace


  2. 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.

    Figure 6. Copy and Paste the customization jar into the workspace


    Click OK all the way through, and now you are ready to scaffold with the customizations.

7. Scaffold with customized templates

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).

8. Conclusion

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.

9. Additional Developer Resources

Thank you for you interest in MyEclipse for Spring. If you are interested in learning more, the following developer resources are available: