Journey SDK Maven plugin

   Temenos Journey ManagerPreviously known as the Transact Platform   |    Platform Developer |  25.04This feature was updated in 25.04

The Journey SDK Maven plugin provides goals and lifecycles to build and deploy Journey Manager (JM) form applications from the Maven command line. Maven plugin goals provide functionality supporting Journey Manager platform development, and can be used in place of the Ant tasks used by all versions of Journey SDK. Two new customized lifecycles, app and svc, join Maven's built-in build lifecycles (default, clean and site) to enhance the Journey SDK CI/CD process. To learn more about this plugin, see Journey Manager SDK Maven Plugin.

Let's learn how to start a new Journey Manager project using the Journey SDK Maven plugin.

Requirements

When you build a Journey Manager project based on the Journey SDK Maven plugin project template, all required dependencies are downloaded from CS Artifactory including the Journey SDK Maven plugin. If you don't have access to CS Artifactory, contact your TJM support representative to request access. When your account is created, you'll receive an email that includes instructions for setting up the settings.xml file. Make sure your Maven settings.xml is configured to connect to the correct Artifactory in order to download the required dependencies.

Project setup

To learn how to setup a Journey SDK Maven project, see Setup Journey SDK > (Optional) Setup a Journey SDK Maven project.

Examples

Examples for all goals and phases are available in Journey SDK Plugin Examples.

  • Run a specific goal

    For example, run the app-scaffold goal:

    mvn initialize tm-sdk:app-scaffold
  • Run a phase

    For example, run the app-package phase:

    mvn initialize app-package

Development Tips

Passing arguments

There are two ways to pass input parameters to a Maven goal: command-line parameters, or POM properties.

  • Command-line parameters:

    Pass command-line parameters to a Maven goal using the -D or --define option. For example:

    mvn initialize tm-sdk:app-scaffold-connect -Dconnection.name="My Connect"
  • POM properties:

    POM properties are added to the pom.xml file. For example:

    <!-- Example parameter for app-scaffold-connect -->
    <connectionName>My Connect</connectionName>

    Then, when you run the goal, the property's value is loaded from the pom.xml file. For example:

    mvn initialize tm-sdk:app-scaffold-connect

Running unit tests

You can run unit tests on the command line or in your preferred IDE.

  • To run a unit test on the command-line:

    Start by running the mvnDebug command:

    mvnDebug initialize tm-sdk:app-scaffold-connect

    Now, you can debug your application on your local machine (using port 8000) by creating and running a remote JVM debug connection.

  • To run a unit test in an IDE such as IntelliJ IDEA:

    Open IntelliJ and configure Groovy Sources, Tests, Resources and Test Resources as shown below, then debug the unit test as required.

Assignable Fluent Services

Assignable Fluent Service feature is now also available via SDK.

Supported templates

  • Assignable Fluent Dynamic Data
  • Assignable Fluent Form Prefill
  • Assignable Fluent Delivery Function
  • Assignable Fluent Function
  • Assignable Fluent Job Action

Scaffold

Develop can create an Assignable Fluent Service from the above templates in the same way as normal fluent service. For example:

mvn initialize tm-sdk:svc-scaffold -Dfluent.service.template="Assignable Fluent Function"

Upon successful creation, two assignable fluent service specific attributes are added to the service-def.json.

The "assignable" attribute indicates it is assignable, and the assignedOrganizations contains the set of assigned organization name (ordered by name) defined in the JM server.

For example:

"assignable": true,
"assignedOrganizations": [
"Client A",
"Client B"        
]

Package, Test, and Deploy

A new property, named assignable, is introduced for svc-package, svc-test, svc-deploy of Assignable Fluent Service.

Package

For svc-package, it has another property, assignableSvcPackageFilesets, to facilitate the grouping of Assignable Fluent Services. Develops can specify the directory of the Assignable Fluent Services in the pom.xml. For example:

<assignableSvcPackageFilesets>
        <fileset>
            <directory>${basedir}/src/main/resources/com/assignable</directory>
            <includes>
                <include>**/service-def.json</include>
            </includes>
        </fileset>
    </assignableSvcPackageFilesets>

Test

When running unit test for assignable fluent service, the first element in the assignedOrganizations set, is used for unit testing. In this example,

"assignedOrganizations": [
"Client A",
"Client B"        
]

The "Client A" will be used for unit testing.

Deploy

Develops can choose to run package, test, and then eventually deploy assignable fluent services through each individual goal. For example:

mvn initialize tm-sdk:svc-package -Dassignable=true
mvn initialize tm-sdk:svc-test -Dassignable=true
mvn initialize tm-sdk:svc-deploy -Dassignable=true

However, for better Developers Experience and CI/CD pipeline, these can be done through a single command:

mvn initialize svc-deploy -Dassignable=true

Global Code Library

Developers can create a dedicate SDK project to build a Global Code Library. There are 2 types of artifacts generated by this project.

  • A ZIP file which is a typical Manager archive used to import the Global Code Library to Manager. This is the default.
  • A JAR artifact that can be used by developers in another SDK project for testing. This is typically a solution SDK project. Developers must add the below snippet to the Global Code Library pom.xml file under the build section if the JAR file artifact is needed.
<plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>4.0.1</version>
            <executions>
              <execution>
                <goals>
                  <goal>compile</goal>
                  <goal>compileTests</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <targetBytecode>17</targetBytecode>
            </configuration>
</plugin>

Define Global Code Library maven coordinates for The Global Code Library project, example below:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.avoka.tm.library</groupId>
  <artifactId>global-code-lib</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <!-- other maven configurations -->
</project>

Below command can scaffold a basic code library class

mvn initialize tm-sdk:code-lib-scaffold

The generated example file is below:

package com.avoka.tm.library.vo

import groovy.transform.TypeChecked

@TypeChecked
class Example {

  static void helloWorld() {
      println 'Hello, World!'
  }

}

With the above settings, developers can run any of the below commands depending on the requirements:

mvn clean initialize code-lib-deploy install
mvn clean initialize code-lib-typecheck install
mvn clean initialize code-lib-deploy
mvn initialize tm-sdk:code-lib-deploy "-Dlib.zip.file=target/global-code-lib.zip"

The built artifact can be also pushed to a remote repository if needed.

Solution Code Library

Developers can also create solution specific Code Library and use it within the solution SDK project. If Code Library unit tests are required, add below snippet to the Global Code Library pom.xml file under the build section.

<plugin>
  <groupId>org.codehaus.gmavenplus</groupId>
  <artifactId>gmavenplus-plugin</artifactId>
  <version>4.0.1</version>
  <executions>
    <execution>
      <id>compile-groovy-test</id>
      <goals>
        <goal>compile</goal>
        <goal>compileTests</goal>
      </goals>
      <configuration>
        <sources>
          <fileset>
            <directory>${project.basedir}/src/main/groovy/com/avoka/tm/library</directory>
            <includes>
              <include>**/*.groovy</include>
            </includes>
          </fileset>
        </sources>
        <testSources>
          <fileset>
            <directory>${project.basedir}/src/test/groovy/com/avoka/tm/library</directory>
            <includes>
              <include>**/*.groovy</include>
            </includes>
          </fileset>
        </testSources>
      </configuration>
    </execution>
  </executions>
  <configuration>
    <targetBytecode>17</targetBytecode>
  </configuration>
</plugin>

The below command will compile and test solutions code library. It will also perform type check, package the code library, and deploy it to TJM along the application package.

mvn clean test initialize app-deploy

Global Code Library in Solution SDK project

Developers can also use the shared/published artifacts built from Global Code Library within a Solution SDK project in combination with Code Libraries specific to the solution project.

The built jar artifact (built from a Global Code Library project) needs to added to standard dependencies section in the SDK solution pom.xml file as well as the dependencies section for tm-sdk-maven-plugin plugin. example below:

<dependency>
          <groupId>com.avoka.tm.library</groupId>
          <artifactId>global-code-lib</artifactId>
          <version>1.0.0-SNAPSHOT</version>
      </dependency>
<plugin>
          <groupId>com.avoka.tm</groupId>
          <artifactId>tm-sdk-maven-plugin</artifactId>
          <version>${version.tm.sdk.and.tm.sdk.plugin}</version>
          <dependencies>
              <dependency>
                  <groupId>com.avoka.tm.library</groupId>
                  <artifactId>global-code-lib</artifactId>
                <version>1.0.0-SNAPSHOT</version>
              </dependency>
          </dependencies>
      </plugin>

The above configuration enables developers to use Global Code Library within the Solution SDK project as a typical maven dependency.

Note

Deploying a solution SDK project doesn't deploy Global Code Library. Global Code Library is deployed independent of the SDK solution project. However, an SDK solution project will deploy the solution Code Library when deployed to TJM.

Next, learn about Continuous Integration.