|
Once the project template is ready, you need to register it with Eclipse to make the template available for use. It is a good practice to group all the files and resources related to the project template together in one folder. For example, if you are writing a project template for a Hello World Application, group all the resources required for this application in a folder "HelloWorld".
To register a project template with Eclipse follow the steps given below:
Create an empty plug-in project from the Eclipse workbench without the source folders.
Create a folder and copy the project template along with all the resources required to create the project. For example, all the hearder files, source files, resource files etc.
Open the plug-in manifest editor and select the
Dependencies
page. For more information on plug-in manifest
editor, refer to PDE
Guide > Getting Started > Basic Plug-in Tutorial
> Plug-in manifest editor.
Click Add
to select
org.eclipse.cdt.templateengine
plug-in from the list.
Select the Extensions
page in the plug-in manifest
editor.
Click Add
to create an extension to the extension-point.
Select the extension-point with ID
org.eclipse.cdt.templateengine.templates
from the list of
extensions-points.
Right-click on the newly added extension, and select
New
>
template
from the context menu.
Choose the new template added in step 6 from the All
Extensions
list.
Specify the wizardId
attribute of the template as
"org.eclipse.cdt.project.ui.NewProjectWizard". This
attribute is mandatory.
Specify the location of the template relative to the plug-in created in step 1. This attribute is mandatory.
Specify a filterPattern
to indicate the build
Configurations for which the template is created. It is a regular expression used
to filter the build Configurations. If the template is designed for a particular
Configuration, it is recommended to specify the filter pattern. For example, If
the template is designed for GCC Configurations, the filter pattern can be ".*gcc".
If the template is designed for multiple build Configurations, you can specify
the filter patterns delimited by "|" .
The New Project wizard filters the available build Configurations based on the filter pattern for the selected template. The filter patterns are matched against the available Configurations' ID to get a list of matching SDKs. This is an optional attribute.
For more information on regular expression patterns, refer to Java API document for java.util.regex.Pattern.
Select an appropriate project type from the
projectType
drop-down list. This is an optional attribute.
Specify the usageDescription
, which is a notation
describing how this template is used. Usually used to filter the list of
templates on offer depending on other wizard attributes. This is an optional
attribute. For more information, refer to Java API document for
java.util.regex.Pattern.
The New Project wizard will list only those templates, which are
relevant for the build Configurations choosen for the project. For a example, if the developer
choose to create a C++ Application for Symbian OS
, the wizard
will list all the templates with the relevant
usageDescription
. Otherwise, for a standard CDT
C++ Project
the wizard will list all the templates, irrespective of
whether the usageDescription
is specified or not.
Specify the pagesAfterTemplateSelectionProvider
,
which is a fully qualified name of the class that implements
org.eclipse.cdt.templateengine.IPagesAfterTemplateSelectionProvider
interface. This is an optional attribute.
After creating the plug-ins and registering the templates, launch a runtime workbench and invoke the New Project wizard to check that the template you added is listed.