Changes for page Custom Project Templates
Last modified by Bastian Triller on 2009/04/11 21:03
From version 22.1
edited by Pascal Robert
on 2007/12/15 18:26
on 2007/12/15 18:26
Change comment:
There is no comment for this version
To version 24.1
edited by Mike Schrag
on 2007/12/11 19:46
on 2007/12/11 19:46
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. probert1 +XWiki.mschrag - Content
-
... ... @@ -1,17 +1,11 @@ 1 - {{toc}}{{/toc}}1 +WOLips 3.3+ supports the definition of custom project templates. These templates support the declaration of custom configuration parameters and the files within the template are processed using the [[Velocity Template Engine>>http://velocity.apache.org/engine/devel/vtl-reference-guide.html]]. 2 2 3 -WOLips 3.3 supports the definition of custom project templates. These templates support the declaration of custom configuration parameters and the files within the template are processed using the [[Velocity Template Engine>>http://velocity.apache.org/engine/devel/vtl-reference-guide.html]]. 4 - 5 5 To use a custom project template, select the "WO Project from Template" option under the WOLips category of the New Project Wizard. 6 6 7 - {{info}}5 +[[image:NewProjectFromTemplate.png]] 8 8 9 - !NewProjectFromTemplate.png!7 +==== Creating a Template ==== 10 10 11 -{{/info}} 12 - 13 -= Creating a Template = 14 - 15 15 The declaration of templates is very simple. The template system looks for folders in the following locations (in the following order): 16 16 17 17 * The ProjectTemplates folder inside of the WOLips templateengine plugin jar ... ... @@ -18,25 +18,25 @@ 18 18 * /Library/Application Support/WOLips/Project Templates 19 19 * YourHomeDirocuments and Settingspplication DataOLipsroject Templates 20 20 * YourHomeDirocuments and SettingsppDataocalOLipsroject Templates 21 -* /Library/Application Support/WOLips/Project Templates 15 +* ,,/Library/Application Support/WOLips/Project Templates,, 22 22 23 -Without any additional metadata, the template system derives the name of the template from the name of the folder in one of the above locations. For instance, if you create a folder named ",,/Library/Application Support/WOLips/Project Templates/Wonder Application," the template system will offer a template named "Wonder Application" in the template selection dialog. Project templates found later in the list of locations above will override those of the same name from earlier in the list. For instance, a "Wonder Application" template found in /Library will overrode a "Wonder Application" template from /Library. ,,17 +Without any additional metadata, the template system derives the name of the template from the name of the folder in one of the above locations. For instance, if you create a folder named ",,/Library/Application Support/WOLips/Project Templates/Wonder Application," the template system will offer a template named "Wonder Application" in the template selection dialog. Project templates found later in the list of locations above will override those of the same name from earlier in the list. For instance, a "Wonder Application" template found in ,,/Library will overrode a "Wonder Application" template from /Library. 24 24 25 -After creating a template folder, you can create a hierarchy of files and folders within that folder. When you create a project using this template, a copy of all of the files and folders in your template will be used to create the new project. It is up to you to declare //all// of the files within a project, including Eclipse project metadata files like .classpath. You can refer to the built-in project templates as a starting point for creating your own custom templates. 19 +After creating a template folder, you can create a hierarchy of files and folders within that folder. When you create a project using this template, a copy of all of the files and folders in your template will be used to create the new project. It is up to you to declare //all// of the files within a project, including Eclipse project metadata files like .classpath. You can refer to the built-in project templates as a starting point for creating your own custom templates. 26 26 27 -That's it For creating static boilerplate templates, you're done. 21 +That's it! For creating static boilerplate templates, you're done. 28 28 29 -= Template Metadata and Template Inputs = 23 +==== Template Metadata and Template Inputs ==== 30 30 31 31 For a static template, the simple process above is enough. However, it's a common requirement to have configuration options for project templates. The WOLips project template engine provides an easy way to declare these options. 32 32 33 -After creating a template using the directions in the above section, you can additionally create a file named "template.xml" inside your project template folder. For instance, in the example above, you would create the file ",,/Library/Application Support/WOLips/Project Templates/Wonder Application/template.xml".,, 27 +After creating a template using the directions in the above section, you can additionally create a file named "template.xml" inside your project template folder. For instance, in the example above, you would create the file ",,/Library/Application Support/WOLips/Project Templates/Wonder Application/template.xml". ,, 34 34 35 35 An example template.xml is below: 36 36 37 37 {{code value="xml"}} 38 38 39 -<?xml version="1.0" encoding="UTF-8"?> 33 + <?xml version="1.0" encoding="UTF-8"?> 40 40 <template name = "Wonder Application"> 41 41 <inputs> 42 42 <input name = "linkToWonderProjects" type = "Boolean"> ... ... @@ -69,7 +69,7 @@ 69 69 70 70 Finally, the input system supports the declaration of enumerated types. By declaring an "options" node that contains an ordered set of "option" nodes, you can define the possible values that the user can provide. In the above example, the "YourFavoriteColor" input defines three options: Red, Green, and Blue. Each option node has a "name" attribute, which will be the value displayed to the user, and a "value" attribute, which will be the actual backing value of the selection. The value of the option should be of the type specified in the "type" attribute of the input. For instance, if you declare the input type to be "Integer," your option values should be integer values (in quotes). 71 71 72 -= Using Template Inputs = 66 +==== Using Template Inputs ==== 73 73 74 74 So now that you have template input defined, you will want to be able to use them. The name use used in the "name" attribute of your input declaration will be the name of the variable in your Velocity context. For instance, in the example above, the Velocity variable "linkToWonderProjects" will be bound to the boolean value corresponding to the user's selection, and can be used just like any other velocity variable. The Apache project provides a [[Velocity reference guide>>http://velocity.apache.org/engine/devel/vtl-reference-guide.html]]. 75 75 ... ... @@ -77,7 +77,7 @@ 77 77 78 78 {{code value="xml"}} 79 79 80 -<?xml version="1.0" encoding="UTF-8"?> 74 + <?xml version="1.0" encoding="UTF-8"?> 81 81 <classpath> 82 82 <classpathentry kind="src" path="Sources"/> 83 83 #if ($linkToWonderProjects) ... ... @@ -97,6 +97,6 @@ 97 97 98 98 {{/code}} 99 99 100 -In addition to variables inside of Velocity templates, you can also use template inputs in folder names. However, because $ is not allowed on some filesystems, we instead surround the variable names with " //" (for instance $someVariable would be//someVariable in the filename or path). As an example, the Wonder Application template has an input named "basePackage" (of type Package), which creates a magic variable named "basePackage//folder" (where the dots are turned into slashes), and the Source folder on the filesystem is named "Wonder Application/Sources///basePackage//folder//".94 +In addition to variables inside of Velocity templates, you can also use template inputs in folder names. However, because $ is not allowed on some filesystems, we instead surround the variable names with "" (for instance $someVariable would be someVariable in the filename or path). As an example, the Wonder Application template has an input named "basePackage" (of type Package), which creates a magic variable named "basePackage//folder" (where the dots are turned into slashes), and the Source folder on the filesystem is named "Wonder Application/Sources/basePackage//folder". 101 101 102 -Happy templating 96 +Happy templating!