Skip to main content

Version: 25.04

Maven Setup for Code Libraries

When creating a new Centralized or Solution SDK project, you will need to configure your Maven project differently, depending on whether you are developing a Centralized Code Library or Solution Code Library.

Overview

Code Libraries require specific Maven configuration to:

  • Compile Groovy code with type checking
  • Generate deployment artifacts (.zip and optionally .jar)
  • Enable unit testing
  • Deploy to Journey Manager

Configuration differs based on project type:

  • Centralized Code Library Projects - projects for shared libraries
  • Solution SDK Projects - projects that include solution-specific libraries

Centralized Code Library project setup

Use this configuration for Code Library projects that will be shared across multiple solutions.

Basic project structure

centralized-code-lib/
├── pom.xml
├── src/
│ ├── main/groovy/com/avoka/tm/library/
│ │ └── [your-code-libraries].groovy
│ └── test/groovy/com/avoka/tm/library/
│ └── [your-tests].groovy
└── target/

Maven coordinates

Define your library's Maven coordinates in pom.xml:

<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>

<!-- Your library's coordinates -->
<groupId>com.avoka.tm.library</groupId>
<artifactId>my-centralized-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>My Centralized Code Library</name>
<description>Shared code libraries for [purpose]</description>

<!-- Parent POM -->
<parent>
<groupId>com.avoka.tm</groupId>
<artifactId>tm-sdk-parent</artifactId>
<version>${tm.sdk.version}</version>
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>

Customize these values

  • groupId - Your organization's group ID
  • artifactId - Unique name for this library (e.g., finance-utils, customer-models)
  • version - Library version (use semantic versioning)
  • name and description - Human-readable metadata

Build configuration

TM SDK Maven Plugin (Essential)

To leverage Code Libraries, you must configure the Journey Manager SDK plugin via the pom.xml file.

JAR Artifact Generation (Optional)

Add this plugin only if you need a .jar artifact for use as a Maven dependency in other projects:

<build>
<plugins>
<!-- Groovy Compilation Plugin -->
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>4.0.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<targetBytecode>17</targetBytecode>
</configuration>
</plugin>
</plugins>
</build>

When to add this

  • If Solution SDK projects will depend on this library
  • If you need IntelliJ/IDE autocomplete for this library in other projects
  • Not needed if only deploying to JM (.zip is generated by default)

Unit Testing Support (Optional)

Add this configuration only if you want to write unit tests for your Code Libraries:

Unit testing configuration
<build>
<plugins>
<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>

<!-- Maven Surefire for test execution -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<includes>
<include>**/*Test.groovy</include>
<include>**/*Spec.groovy</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

Complete example pom.xml

Here's a complete example combining all optional features:

Complete pom.xml example
<?xml version="1.0" encoding="UTF-8"?>
<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>

<parent>
<groupId>com.avoka.tm</groupId>
<artifactId>tm-sdk-parent</artifactId>
<version>25.04.0</version>
</parent>

<groupId>com.company.tm.library</groupId>
<artifactId>shared-utilities</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Shared Utilities Library</name>
<description>Common utility functions and data models</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<tm.sdk.version>25.04.0</tm.sdk.version>
</properties>

<dependencies>
<dependency>
<groupId>com.avoka.tm</groupId>
<artifactId>tm-sdk</artifactId>
<version>${tm.sdk.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>2.3-groovy-4.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- TM SDK Plugin -->
<plugin>
<groupId>com.avoka.tm</groupId>
<artifactId>tm-sdk-maven-plugin</artifactId>
<version>${tm.sdk.version}</version>
<extensions>true</extensions>
</plugin>

<!-- Groovy Compiler with Test Support -->
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>4.0.1</version>
<executions>
<execution>
<id>compile-groovy</id>
<goals>
<goal>compile</goal>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
<configuration>
<targetBytecode>17</targetBytecode>
</configuration>
</plugin>

<!-- Test Runner -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
</plugin>
</plugins>
</build>
</project>

Solution SDK project setup

Use this configuration when adding Code Libraries to a Solution SDK project.

Add Code Libraries to existing solution

Solution SDK projects can include Code Libraries alongside forms, services, and other solution components.

Project structure

my-solution-sdk/
├── pom.xml
├── forms/
├── services/
├── src/main/groovy/com/avoka/tm/library/
│ └── [solution-code-libraries].groovy
└── build.properties

Configuration in pom.xml

Solution SDK projects typically already have the TM SDK plugin configured. No additional plugin configuration is needed for Solution-Specific Code Libraries. Verify your pom.xml includes tm-sdk-maven-plugin.

Add centralized library dependencies

To use a Centralized Code Library in your solution, add it as a dependency in two places:

Dependency configuration example
<!-- Standard dependencies section -->
<dependencies>
<!-- Other dependencies... -->

<!-- Centralized Code Library -->
<dependency>
<groupId>com.avoka.tm.library</groupId>
<artifactId>shared-utilities</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>

<!-- Also in the plugin dependencies -->
<build>
<plugins>
<plugin>
<groupId>com.avoka.tm</groupId>
<artifactId>tm-sdk-maven-plugin</artifactId>
<version>${tm.sdk.version}</version>
<extensions>true</extensions>
<dependencies>
<!-- Centralized Code Library -->
<dependency>
<groupId>com.avoka.tm.library</groupId>
<artifactId>shared-utilities</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Why both locations?

  • Standard <dependencies> - For IDE autocomplete and local compilation
  • Plugin <dependencies> - For SDK build tools and type checking

Package naming conventions

Code Libraries must follow Java package naming conventions.

Centralized Libraries (Global)

com.avoka.tm.library.global
com.avoka.tm.library.global.model
com.avoka.tm.library.global.util

Solution Libraries

com.avoka.tm.library.model
com.avoka.tm.library.mysolution
com.company.tm.library.loanapp

Verification

After setup, verify everything is configured correctly:

# Check Maven can resolve dependencies
mvn dependency:tree

# Verify SDK plugin is active
mvn help:effective-pom | grep tm-sdk-maven-plugin

# Test connection to JM
mvn initialize tm-sdk:code-lib-compare

If successful, your configuration is correct!