The index file contains a list of all available templates.
This file must be located in the directory given as Base URL in the plugin preferences.
The name must match the name given in the Indexfile column (see [Installation]).
The index file must contain the root tag template-index:
<template-index>
<template name="Simple Java project" url="simplejavaproj.xml"/>
</template-index>
The index file contains one line per template.
This line defines a template named "Simple Java project", the template definition file is called "simplejavaproj.xml":
<template name="Simple Java project" url="simplejavaproj.xml"/>
For each template, there is a description file that is referenced in the index file.
The description file must contain the root tag project-template:
<project-template name="simplejavaproj">
<description>...</description>
<nature id="..."/>
<buildpath varpath="..."/>
<file url="..." dest="..."/>
<variable name="..." default="...">...</variable>
</project-template>
description is the description of the template as shown in the New Project wizard below the template listbox.
This can be a single sentence as well as a detailed description:
<description>A simple Java project.</description>
nature can be specified to preconfigure the project that will be created.
These lines enable Findbugs and Checkstyle for the new project:
<nature id="edu.umd.cs.findbugs.plugin.eclipse.findbugsNature"/>
<nature id="com.atlassw.tools.eclipse.checkstyle.CheckstyleNature"/>
buildpath contains references to external jarfiles that are used in the new project. More jarfiles can be added in the New Project wizard after selecting the template.
This line will include "junit.jar" in all projects created from the template (JAVA_LIBS is a classpath variable):
<buildpath varpath="JAVA_LIBS/junit.jar"/>
variable defines all variables that can be set for the template. All variables will be shown in the table in the New Project wizard after the template has been selected.
The content of the <variable> tag is a short description of the variable that will be displayed below the table if a variable is selected.</variable>
The first and the second line define the simple variables "ClassName" with the default value "SimpleJavaClass" and "PackageName" with the default value "de.cenit.eb.sm.finca.sandbox".
The second line defines the variable PackageDir. The source value for this variable is taken from PackageName. All occurrences of "." in the package name are replaced by "/" so the final value of PackageDir will be "de/cenit/eb/sm/finca/sandbox".
<variable name="ClassName" default="SimpleJavaClass">The main class</variable>
<variable name="PackageName" default="de.cenit.eb.sm.finca.sandbox">The package name</variable>
<variable name="PackageDir" source="PackageName" regex="\." replacement="/" >The package source dir (subdir of src).</variable>
file defines all files that are used to create the new project.
This line defines that the file "ClassName.java" is part of the template. When the file is copied from the template to the destination directory, the variables "$PackageDir$" and $ClassName$" will be replaced by their corresponding values. Using the variable settings from the example above, the file would be copied to "src/de/cenit/eb/sm/finca/sandbox/SimpleJavaClass.java".
<file url="files/src/PackageDir/ClassName.java" dest="src/$PackageDir$/$ClassName$.java"/>
All referenced files are located in the files subdirectory of the Base URL given in the plugin preferences.
The files can contain references to the variables specified in the template description file. During creation of the new project from the template (as soon as you click Finish in the New Project Wizard), all references to variables inside the files will be replaced by their corresponding values.
This is an example for a simple Java class file that uses the variables "ClassName" and "PackageName":
package $PackageName$;
/** @todo description of $ClassName$ */
public class $ClassName$
{
/** @todo description of main */
public static void main(String[] args)
{
// @todo Auto-generated method stub
System.exit(0);
}
}
You can download a simple example template from http://protewiz.svn.sourceforge.net/viewvc/protewiz/trunk/templates/.