Skip to main content

Version: 25.04

Create a Code Library Quick Start

Journey Manager allows you to create different code libraries that can be used in your solutions by various Groovy services or deployed as global code libraries. You can also use this UI to review and troubleshoot code libraries.

You can create a code library using one of following options:

Manager allows you to create and run code libraries using the SDK Maven plugin. This is a preferred approach for developers because it can be done from an IDE or a CI/CD pipeline.

The plugin provides the following goals:

Let's look at how you can use these goals. As you have learned in Code Library Overview, code libraries can be used on global, organization, and solution levels. Let's delve into some details. We'll start with the solution level.

Create a Solution Code Library

A solution can be a bunch of services implementing specific customer onboarding flow. There can be common functionality among the services, so it makes sense to move it into a code library. The generic approach is to create a code library and then create a service that uses the code library. Finally, they are both deployed as a package into your Manager instance. In this scenario, the code library is unique for this solution only.

To create a solution code library:

  1. Open your solution project.
  2. Navigate to the pom.xml and open it.
  3. Update the libPackageName and libClassName elements with a new code library details, for example, com.avoka.tm.library.vo and Example, respectively. Update code library details
  4. Open the app-package-def.json configuration file and add the service JSON configuration file names under services properties. Add service configurations
  5. Run the mvn initialize tm-sdk:app-scaffold-func command to create the classes and functions defined in the configuration files above.
  6. Run the mvn initialize tm-sdk:lib-scaffold command to create a code library specified with the libPackageName and libClassName elements.
  7. Navigate to the new code library Groovy class under the main/groovy/com/ directory.
  8. Open the code library class, for example, Example.groovy and update the Groovy script to implement desired functionality.
  9. Open the service, for example, MyFluentFuncForm.groovy and update the Groovy script to call methods of the Example.groovy code library. Make sure you add the code library package name as the import statement. Update the Groovy script
  10. Run the mvn initialize app-deploy command to perform a type check and then deploy a form, the service and code library as an application package into Manager.
  11. View forms to check the form is deployed.
  12. View code libraries to check the code library is available. Open the code library Groovy script in UI to review it.
  13. Open the form to see it renders correctly and executes the service and code library as expected. Check the Groovy Log of the service to verify this.

Create a Centralized Code Library

You often need to create a project that contains code libraries only, so it can be deployed in Manager and used by various services in different organizations.

To create a global code library:

  1. Open your global library project.
  2. Navigate to the pom.xml and open it.
  3. Update the libPackageName and libClassName elements with a new code library details, for example, com.avoka.tm.library.vo and GlobalLib, respectfully.
  4. Run the mvn initialize tm-sdk:lib-scaffold command to create a code library specified with the libPackageName and libClassName elements.
  5. Update the pom.xml with another libPackageName and libClassName elements, for example, com.avoka.tm.library.util and GlobalUtils, respectfully.
  6. Run the mvn initialize tm-sdk:lib-scaffold command to create another code library.
  7. Run the mvn initialize lib-deploy command to package and deploy these code libraries to Manager.
  8. View code libraries to check two new code libraries are available. Open the code libraries Groovy scripts in UI to review them.

Use a Centralized Code Library

Sometimes you want to use a centralized code library in your solution project.

To use a centralized code library in a solution:

  1. Open your global library project.
  2. Navigate to the pom.xml and open it.
  3. Update artifactID element with the gmavenplus-plugin value to tell Maven what Groovy source to pack.
  4. Run the mvn install command to create a JAR file with all code libraries as described in the Global Code Libraries sections above.
  5. Open your solution project.
  6. Open the pom.xml file and update the version.shared-code-lib element with the JAR file you created, for example, MyCentralizedLib.
  7. Update the dependency and artifactId elements with a new code library details respectfully.
  8. Run the mvn clean install command.
  9. Open the service, for example, MyFluentFuncForm.groovy and update the Groovy script to call methods of the centralized code library.
  10. Run the mvn initialize lib-deploy command to package and deploy these code libraries to Manager.
  11. View code libraries to check two new code libraries are available.