Tigerstripe Headless Generation Tutorial
< To: Tigerstripe_Tutorials
This tutorial will show you how to configure Tigerstripe to run code generations in a headless environment. This will allow you to incorporate Tigerstripe's code generation functionality into a build chain using many of the commonly available build tools, specifically Maven 2.
- 1 Tigerstripe Installation
- 2 Importing an Example Model
- 3 Installing Tigerstripe Generators
- 4 Running a Generation from the Command Line
- 5 Running a Generation from a Maven2 Build
See the Tigerstripe Installation Tutorial page for instructions on installing the Tigerstripe Workbench.
Importing an Example Model
This example project is also available from the CVS repository. If you wish to get the files from CVS you may skip the rest of this step.
- Download the sample Tigerstripe model project OrderManagement.zip.
- Start Eclipse and then open the Tigerstripe Workbench perspective.
- Import the sample project, OrderManagement.zip into the Tigerstripe Workbench.
- Verify that the project is in your Tigerstripe Explorer pane.
Installing Tigerstripe Generators
Tigerstripe Generators are pluggable components that allow users to define rules and conventions for code that is generated from a Tigerstripe Model Project. Several generators are currently available, and in many cases, you may want to write your own. For more information on writing you own Tigerstripe Generators see Tigerstripe Tutorials, Code Generation.
Obtaining the Tigerstripe Generator
The generator used in this tutorial is in the Tigerstripe CVS repository at:
Alternatively, it can be downloaded as a .zip file, export-xml.zip. If downloading the .zip file, follow the procedure described in the Importing an Example Model Section to import the project into your workspace.
Installing the Generator
- Open the generator's configuration (ts-plugin.xml) for editing.
- From the Overview panel, Testing section, click the
Package and deploy this plugin. Hyperlink.
- Click "OK" in the Deploy New Plugin dialog.
- Click "OK" in the export-xml Plugin dialog.
- Verify Generator installation.
Running a Generation from the Command Line
Now that the Tigerstripe workbench is set up and the Tigerstripe generators have been installed and tested you can invoke a generation run from the command line. The Eclipse mechanism for running in a headless environment will be used to accomplish this.
The following command/syntax invokes a headless generation:
eclipsec -nosplash -data <workspace> -application org.eclipse.tigerstripe.workbench.headless.tigerstripe <referenced projects> <generation project>
- <workspace> - The path of the workspace that contains the required projects
- <generation project> - The project that will be generated. Defined by the key/value pair:
- <referenced projects> - The referenced projects required for generation. Defined by the key/value pair:
Run a headless model generation using the Tigerstripe Workbench
@echo off REM Set below to match your current configuration set ECLIPSE_HOME=C:\eclipse set WORKSPACE=C:\workspace set HEADLESS_PLUGIN=org.eclipse.tigerstripe.workbench.headless.tigerstripe set PROJECT=GENERATION_PROJECT=%WORKSPACE%\OrderManagement REM Use below to define referenced projects REM set REFERENCE_ONE= PROJECT_IMPORT=%WORKSPACE%\ReferencedProjectOne REM set REFERENCE_TWO= PROJECT_IMPORT=%WORKSPACE%\ReferencedProjectTwo %ECLIPSE_HOME%\eclipsec -nosplash -data %WORKSPACE% -application %HEADLESS_PLUGIN% %PROJECT%
- Download wincmdline.zip (above) and unzip the .bat file in a handy location
- Verify that the .bat file parameters are set correctly for your system
- Execute the batch file to initiate model generation (Note: output may vary based on version)
- Verify generation by navigating to <workspace>OrderManagement\target\tigerstripe.gen\xml. Verify that OrderManagement.xml is a xml based representation of the example model
Running a Generation from a Maven2 Build
Once the Tigerstripe workbench is set up and the Tigerstripe generators have been installed and test you can use a supplied Maven plug-in to invoke a generation. This tutorial assumes that you have installed Maven correctly and are familiar with it's use. See http://maven.apache.org/ for information on Maven.
Running a Tigerstripe Generation via Maven
Obtain the source from the following CVS repository location:
- module = org.eclipse.tigerstripe/misc/tigerstripe-maven-plugin
- Install the plugin to your local Maven repository by running
mvn installfrom the tigerstripe-maven-plugin root directory.
- Create and set the ECLIPSE_HOME environment variable.
- Click Start and then click Control Panel.
- Double-click System.
- On the Advanced tab, click Environment Variables.
- Under System variables, click New.
- In the Variable Name box type ECLIPSE_HOME, in the Variable Value box type your path to your Eclipse installation (c:\eclipse, for example), and then click OK.
- Click OK.
- Create a Maven project for Tigerstripe generation.
- Type mvn
- Archetype: 15
- groupId: com.ordermgmt
- artifactId: ts-generation
- select default for version (1.0-SNAPSHOT)
- package: com.ordermgmt (this is not used here, but required for project generation)
- Type "Y" when prompted.
- Type mvn
- Change to the ts-generation directory and open up the pom.xml file in a text editor. Enter the following build section into the file.
<build> <plugins> <!-- run tigerstripe generations --> <plugin> <groupId>tigerstripe</groupId> <artifactId>maven-tigerstripe-plugin</artifactId> <version>1.2</version> <executions> <execution> <!-- fill in your specific information here --> <configuration> <workspace>C:\workspace</workspace> <projects> <param>C:\workspace\OrderManagement</param> </projects> <generationProject>C:\workspace\OrderManagement</generationProject> </configuration> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
Now, from the root directory of the ts-generation directory type
mvn install. The generation will run on the workspace defined. You may check the output directory (target\tigerstripe.gen, by default) in the Eclipse workspace to verify that the expected artifacts were generated.
See the following section for complete information on the tigerstipe-maven-plugin configuration.
Tigerstripe Maven Plugin
- Requires a Maven 2.0 project to execute
- Automatically executes within the lifecycle phase: generate-sources
|workspace||String||The location of the Eclipse workspace that will be used for the generation.|
|projects||String||A list of all Tigerstripe projects required for the generation, including the generation project and all referenced projects.|
|generationProject||String||The primary Tigerstripe project.|