Converting existing function classes without Eclipse

You can convert functions that were written for HCL DevOps Test Integrations and APIs (Test Integrations and APIs) 4 to work with 5 or later, without Eclipse.

About this task

Note: The following steps assume that Test Integrations and APIs is installed in C:\Program Files\HCL\DevOpsTestAPI, that the Installation Manager shared resources directory is installed in C:\Program Files\HCL®\HCL®IMShared\, and that you are using a Windows Command Prompt. However, running the commands from a Linux Terminal is also supported and the Installation Manager shared resources directory is installed on Linux systems in /opt/HCL®/HCL®IMShared/.

Procedure

  1. Create a folder in which to develop your custom function. For example, c:\customFunction.
  2. Create folders for the source and the build output. For example, c:\customFunction\src and c:\customFunction\build.
  3. Copy the plugin.xml file and the META-INF directory from C:\Program Files\HCL\DevOpsTestAPI\examples\FunctionsSamplePlugin into the build directory. Both the plugin.xml file and the META-INF directory must be copied to the same target directory (C:\customFunction\build).
  4. Create the required directory structure under src to contain your custom function code. If you have existing code, copy the root package and all sub packages under the src folder. For example: C:\customFunction\src\com\samples\functions\FormatDate.java.
    An example directory structure follows:

    Example directory structure

    Except in the src folder, if you compile your own function, you have your own Java classes in a similar folder hierarchy. For example:

    Example src directory structure

  5. Remove the register() method.
  6. Change the visibility of the default constructor to be public. No other visibility (for example, protected) can be used, otherwise an exception is generated when you try to execute the function.
  7. Remove the super(String, String, int, int) call in the default constructor.

    This super constructor does not exist anymore, so any calls to it produce an error. This call is replaced by the information that is contained in the extension definition.

  8. Remove the method getSyntax(). This information is now contained in the extension definition.
  9. In your command prompt or terminal, from the C:\customFunction\src folder compile the custom function into the build directory, such as by running the following command:
    Note: Run the javac executable from the Java Development Kit (JDK). If the commands shown do not find that executable, add the full path to the location of the executable to the beginning of each command.

    javac -d ../build -classpath .;"c:/Program Files/HCL/HCLIMShared/plugins/*" com/samples/functions/FormatDate.java

    Note: If the source contains multiple Java files, you must specify each file in the command. For example, if you use the second directory structure above, the command is:
    javac -d ../build -classpath .;"c:/Program Files/HCL/HCLIMShared/plugins/*" com/mycompany/myfunction/MyFunction.java com/mycompany/myfunction/MyUtilities.java

    or

    javac -d ../build -classpath .;"c:/Program Files/HCL/HCLIMShared/plugins/*" com/mycompany/myfunction/*.java
    On a Linux systems, the command is:
    javac -d ../build -classpath .:"/opt/HCL/HCLIMShared/plugins/*" **/*.java
  10. Edit MANIFEST.MF, which is in the META-INF directory under the build directory, for example, META-INF/MANIFEST.MF and change the following values:
    Value Change to...
    Bundle-Name Enter a descriptive name for the plug-in. For example, Format Date Function.
    Bundle-SymbolicName Enter a unique ID that describes your plug-in. This ID must be different from any other plug-in, as two plug-ins with the same ID cannot be loaded at one time. Do not change the singleton:=true attribute.
    Bundle-Vendor Enter the name of your company or name of any other provider.
    An example of a manifest file follows:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 10.0-b19 (Sun Microsystems Inc.)
    Bundle-ManifestVersion: 2
    Bundle-Name: The Function That Does Exactly What I Need
    Bundle-SymbolicName: com.mycompany.myfunction;singleton:=true
    Bundle-Version: 1.0.0
    Bundle-Vendor: My Company
    Import-Package: com.ghc.ghTester.expressions

    Replace the values for Bundle_Name, Bundle-SymbolicName, and Bundle-Vendor with values your own. The Bundle-SymbolicName value does not have to match the Java package name in which the function Java classes are located.

  11. Open plug-in.xml that is in your build directory, in a text editor and update the values.
  12. In a command prompt or terminal, from the c:\customFunction\build directory, create a JAR file that contains your custom function classes, MANIFEST.MF, and plug-in.xml.

    For example, you can use the following command:

    Note: Run the jar executable from the Java Development Kit (JDK). If the commands shown do not find that executable, add the full path to the location of the executable to the beginning of each command.

    jar cvfm custom-function-plug-in_1.0.0.jar META-INF\MANIFEST.MF com plugin.xml

    Note: You can choose any name for your JAR file, but you must follow a convention that prevents conflicting names.
  13. Copy the new JAR file into the Functions folder of your project.
    Note: An example of how the plug-in looks can be found under C:\Program Files\HCL\DevOpsTestAPI\examples\FunctionsSamplePlugin.

What to do next

When you create the function, follow the instructions to load the function into Test Integrations and APIs. See Configuring the function in DevOps Test Integrations and APIs.