# How to register a project template with CDT

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 CDT follow the steps given below:

1. Create an empty plug-in project from the Eclipse workbench without the source folders.

2. Create a new folder to contain the template project's content e.g. "MyExampleProject/templates/MyExampleTemplate". Copy the project template.xml along with all the resources required to create the project. For example, all the header files, source files, resource files etc.

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

4. Click `Add` to select `org.eclipse.cdt.core` and `org.eclipse.cdt.ui` plug-ins from the list.

5. Select the `Extensions` page in the plug-in manifest editor.

6. Click `Add` to create an extension to the extension-point.

7. Select the extension-point with ID `org.eclipse.cdt.core.templates` from the list of extension-points.

8. Right-click on the newly added extension, and select `New` > `template` from the context menu. The first one has already been added for you, `"(template)"`.

9. Select the new template added in the previous step from the `All Extensions` list. Its name is initially `"(template)"`.

10. Specify the `id` attribute of this template contribution, for example "com.foobar.templates.contrib.MyTemplate1". This attribute is mandatory. The id need not be the same as the template id (from template.xml). This allows contributing the same template.xml multiple times. It will replace `"(template)"` in the list.

11. Specify the location of the template XML file, relative to the plug-in created in step 1. This attribute is mandatory.

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

13. Specify the project type you wish the template to be associated with. The project type id can be found by looking at the project types contributed to the buildDefinitions extension point. For more information about project types, see New project information in the What's New in CDT Build section, especially the section "What are the general project type entries?". This attribute is mandatory.

14. Specify the `pagesAfterTemplateSelectionProvider`, which is a fully qualified name of the class that implements `org.eclipse.cdt.ui.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.

## See also:

- How to develop templates

- Example template