# Generate application model code

This topic includes information on the different ways to generate application model code.

In this topic:

## Methods for generating the code file

Application models include two types of files: an XML file (.tsrx) and a code file (.tsrx.cs or .java). The code file is generated from the XML file. For details, see Overview.

The code file can be generated in the following ways:

- The LeanFT IDE plugin automatically generates the code file when the LeanFT project is opened in the IDE.
- Using a command line tool. This method is recommended when you want to generate the code file or multiple code files without opening your LeanFT projects. For details, see AppModel code generation tool.
- For Maven-based projects, we recommend that you use the Maven plugin (Mojo). Use this method to automatically generate the code when the project is built. For details, see Maven application model generator plugin.

Back to top

## AppModel code generation tool

Use the AppModel code generation tool to generate the application model code files. This is a useful method when you upgrade LeanFT, especially, when dealing with multiple files. For details, see Upgrade LeanFT.

There are two tools: one for Java and one for C#. Use the one relevant for your project.

Run the tool for every project that includes an application model.

You can run the tool in one of the following modes:

- Single file mode. Generates a single application model from a single .tsrx file.
- Source folder mode. Generates application models for all .tsrx files under the Source folder.

To run the Java tool

Location:

Windows: <LeanFT installation folder>\Tools\AppModelCodeGenerator\Java\

Linux/Mac: <LeanFTInstallation>/Tools/appmodel-code-generator/Java

Single file mode format:

    java -jar appmodel-code-generator.jar <tsrx path> -package <package name> -outputDir <output directory> -inPlace -sdk <sdk standalone jar>

Usage

Argument | Description
--- | ---
<tsrx path> | The full path to the .tsrx file.
-package (mandatory) | The package name of the generated application model java file. Example: com.company
-outputDir | Sets the directory to the starting place of the generated file package. Example: if the package is com.company and output directory is set to /tmp, then the generated file will be placed in /tmp/com/company. Note: You must supply either -outputDir or -inPlace (not both).
-inPlace | The generated file will be placed in the same folder as the .tsrx file. Note: You must supply either -outputDir or -inPlace (not both).
-sdk (optional) | The path to the sdk standalone JAR. The default is the JAR from the LeanFTinstallation. Note: You must use this argument if you run the tool on a machine without a LeanFT installation.

Source folder mode format:

    java -jar appmodel-code-generator.jar <Source folder path> -outputDir <output directory> -inPlace -sdk <sdk standalone jar>

Usage

Argument | Description
--- | ---
<Source folder path> | The path of the source folder. The source folder is the root folder for your Java project's source files. If you set only this parameter, then the files will be generated to the appmodels folder next to the source folder.
-outputDir (optional) | Sets the directory to the starting place of the generated files package. Example: if the package is com.company and output directory is set to /tmp, then the generated file will be placed in /tmp/com/company. Note: You can supply either -outputDir or -inPlace (not both).
-inPlace (optional) | The generated files will be placed in the same folder as the .tsrx file. Note: You can supply either -outputDir or -inPlace (not both).
-sdk (optional) | The path to the sdk standalone JAR. The default is the JAR from the LeanFTinstallation. Note: You must use this argument if you run the tool on a machine without a LeanFT installation.

To run the C# tool

Location:

Windows: <LeanFT installation folder>\Tools\AppModelCodeGenerator\DotNet\

Single file mode format:

    AppModelCodeGenerator.exe <tsrx path> -namespace <namespace name> -outputDir <output directory> -inPlace -sdk <sdk dll>

Usage

Argument | Description
--- | ---
<tsrx path> | The full path to the .tsrx file.
-namespace(mandatory) | The namespace name of the generated application model C# file. Example: LFT.TESTS
-outputDir | Sets the directory to the starting place of the generated file package. Example: if the namespace is LFT.TESTS and output directory is set to c:\tmp, then the generated file will be placed in c:\tmp\LFT\TESTS. Note: You must supply either -outputDir or -inPlace (not both).
-inPlace | The generated file will be placed in the same folder as the .tsrx file. Note: You must supply either -outputDir or -inPlace (not both).
-sdk (optional) | The path to the sdk DLL. The default is the DLL from the LeanFTinstallation. Note: You must use this argument if you run the tool on a machine without a LeanFT installation.

Source folder mode format:

AppModelCodeGenerator.exe <Source folder path> -namespace <namespace name> -inPlace -outputDir <output directory> -sdk <sdk dll>

Usage

Argument | Description
--- | ---
<Source folder path> | The path of the source folder. If you set only this parameter, then the files will be generated to the appmodels folder next to the source folder.
-namespace(mandatory) | The to level namespace name of the generated application model C# file. Example: LFT.TESTS
-outputDir (optional) | Sets the directory to the starting place of the generated file package. Example: if the namespace is LFT.TESTS and output directory is set to c:\tmp, then the generated file will be placed in c:\tmp\LFT\TESTS. Note: You can supply either -outputDir or -inPlace (not both).
-inPlace (optional) | The generated file will be placed in the same folder as the .tsrx file. Note: You can supply either -outputDir or -inPlace (not both).
-sdk (optional) | The path to the standalone sdk DLL. The default is the DLL from the LeanFTinstallation. Note: You must use this argument if you run the tool on a machine without a LeanFT installation.

Back to top

## Maven application model generator plugin

The Maven application model generator plugin can be used to automatically generate application model code whenever a Maven-based project is built.

Perform the following for each Maven-based project.

Dependencies

The application model code generator Mojo is dependent on the following JARs:

- LeanFT common and SDK JARs.

  Make sure that they are installed in your local or remote repository. For details, see Prerequisites for Maven-based projects.

- AppModel code generator (helper) JAR.

  To deploy the JAR to your organization's repository, run the following command:

  mvn deploy:deploy-file

  -DpomFile=<path-to-pom>

  -Dfile=<path-to-file>

  -DrepositoryId=<id-to-map-on-server-section-of-settings.xml>

  -Durl=<url-of-the-repository-to-deploy>

  To install the JAR to your local repository, run the following command:

  mvn install:install-file

  -Dfile=<path-to-file>

  -DpomFile=<path-to-pomfile>

  The path to the JARs and POMs is:

  - Windows: <LeanFTInstallation>\Tools\AppModelCodeGenerator\Java
  - Linux/Mac: <LeanFTInstallation>/Tools/appmodel-code-generator/Java

  JAR | POM
  --- | ---
  appmodel-code-generator-helper.jar | appmodel-code-generator-helper-pom.xml

To configure the plugin

Select the LeanFT version you are using:

14.50

14.51

14.52

14.53

1. Install the Mojo to your Maven repository. (Follow the instructions in Dependencies.)

   LeanFT version | JAR | POM
   --- | --- | ---
   14.50 | appmodel-code-generator-mojo-14.50.0.jar | appmodel-code-generator-mojo-14.50.0-pom.xml

   LeanFT version | JAR | POM
   --- | --- | ---
   14.51 | appmodel-code-generator-mojo-14.51.0.jar | appmodel-code-generator-mojo-14.51.0.jar

   LeanFT version | JAR | POM
   --- | --- | ---
   14.52 | appmodel-code-generator-mojo-14.52.0.jar | appmodel-code-generator-mojo-14.52.0.jar

   LeanFT version | JAR | POM
   --- | --- | ---
   14.53 | appmodel-code-generator-mojo-14.53.0.jar | appmodel-code-generator-mojo-14.53.0.jar

2. Enable the plugin.

   - Projects created in LeanFT 14.02 or before:

     Open the project pom.xml file and add the following section under the plugins element:

         <plugin>
         	<groupId>com.hpe.lft</groupId>
         	<artifactId>appmodel-generator-mojo</artifactId>
         	<version>14.50.0</version>
         	<executions>
         		<execution>
         			<phase>validate</phase>
         			<goals>
         				<goal>generate</goal>
         			</goals>
         		</execution>
         	</executions>
         	<!--optional parameters -->
         	<configuration>

         	</configuration>
         </plugin>

         <plugin>
         	<groupId>com.hpe.lft</groupId>
         	<artifactId>appmodel-generator-mojo</artifactId>
         	<version>14.51.0</version>
         	<executions>
         		<execution>
         			<phase>validate</phase>
         			<goals>
         				<goal>generate</goal>
         			</goals>
         		</execution>
         	</executions>
         	<!--optional parameters -->
         	<configuration>

         	</configuration>
         </plugin>

         <plugin>
         	<groupId>com.hpe.lft</groupId>
         	<artifactId>appmodel-generator-mojo</artifactId>
         	<version>14.52.0</version>
         	<executions>
         		<execution>
         			<phase>validate</phase>
         			<goals>
         				<goal>generate</goal>
         			</goals>
         		</execution>
         	</executions>
         	<!--optional parameters -->
         	<configuration>

         	</configuration>
         </plugin>

         <plugin>
         	<groupId>com.hpe.lft</groupId>
         	<artifactId>appmodel-generator-mojo</artifactId>
         	<version>14.53.0</version>
         	<executions>
         		<execution>
         			<phase>validate</phase>
         			<goals>
         				<goal>generate</goal>
         			</goals>
         		</execution>
         	</executions>
         	<!--optional parameters -->
         	<configuration>

         	</configuration>
         </plugin>

   - Projects created in LeanFT 14.03 or after:

     Open the project pom.xml file and uncomment the Application model generator plugin section.

3. (Optional) Configure where the generated code file is placed.

   By default, the file is generated under the appmodels folder in the project. To change the location, do the following:

   1. copy the following code into the configuration element in the Maven plugin section in the pom.xml:

          <!--The output directory of the generated application models.The Default is the appmodels folder under the project-->

          <!--<outputDir>set_path</outputDir> -->

          <!--If set to true, the  application models will be generated next to the tsrx files. Mutually exclusive with the outputDir parameter -->

          <!--<inPlace>true</inPlace> -->

   2. Uncomment either the outputDir or the inPlace element, and edit as required.
4. Save your changes to the file.

Back to top

See also:

- Upgrade LeanFT

https://admhelp.microfocus.com LeanFT 8942
Tips to improve your search results...TOC Lean Functional Testing Help Center LeanFT Help Center 14.50 - 14.53 All View Local Help Center View Online Help Center back Go back in browser history forward Go forward in browser history Remove search highlights next topic Go to next topic previous topic Go to previous topic Print the current topic Version:(Undefined variable: _rscC_Basic_Variables.FloatingTocShow)