ALTERNATIVE: Maven Plugin
The SeaLights Maven Plugin offers an alternative method for integrating SeaLights into the CI
Prerequisite: You have completed Phase 2: Advanced Coverage Analytics
The SeaLights Maven plugin is designed to wrap the entire process (Build Scan + Test Listener functions) into the Maven lifecycle, allowing seamless integration with the build tool.
This solution uses the build scanner.jar file as well as a JSON configuration file. Once the jar is executed specifying the configuration file, the pom.xml files of the Maven project are altered to incorporate the SeaLights plugin. This can be reversed using another CLI command.
SeaLights Maven plugin operates during specific Maven lifecycle phases:
Build Scanner is executed during
process-classesTests executed during the
testphase are captured
The option IncludeResources will add the Sealights' text files (sltoken and buildSessionId) to the target/classes folder during process-classes. These two text files will be added automatically to the artifact (.jar, .war,...) during the package phase as they're already placed in the relevant folder.
Prerequisites
The following versions are the minimum required for integration with Maven test runners:
Surefire - version 2.8 and above, recommended is 2.22.2 and above.
Implementation Steps
Download the SeaLights Java Agent
Download the latest version of the SeaLights Java Agent.
There are two agent files
Build Scanner - sl-build-scanner.jar
Test Listener - sl-test-listener.jar
These agent files can be downloaded from: https://agents.sealights.co/sealights-java/sealights-java-latest.zip
Example CLI commands for downloading the SeaLights Java Agent:
# Download the latest Java agent
wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip
# Extract the agent
unzip -oq sealights-java-latest.zip
#validate the agent version
echo "Sealights Java Agent version used is:" `cat sealights-java-version.txt`Create a configuration file
This step allows you to set any necessary configuration in a dedicated configuration file, which will be used when adding the SeaLights Maven Plugin details to your project's pom.xml
Minimum Required Parameters for this configuration:
tokenfile- Path to the agent token file. Note: The token can also be placed in a file namedsltoken.txtin the same directory as the agent. In that case, this parameter is not required.appname- The name of your component. This name will appear in the SeaLights dashboard and reports. This can be any name that represents your component.branchname- Git branch name (defaults to "main" if not specified)buildname- A unique identifier that represents the current build of your component — for example, the CI build number, a timestamp, or a custom name (as long as it is unique).packagesIncluded- A comma-separated list of packages composing the application. Specifies which Java packages SeaLights should monitor for coverage. By default, SeaLights may analyze all packages, but explicitly setting this improves performance.executionType- Set to "full"
Additional Recommended Parameters:
createBuildSessionId- set to truerecursive- set to true
Example Configuration File:
{
"executionType": "full",
"tokenFile": "sltoken.txt",
"createBuildSessionId": true,
"appName": "<component-name>",
"branchName": "<branch-name>",
"buildName": "<build-name>",
"packagesIncluded": "*com.example.*",
"recursive": true,
}Additional optional parameters may be found here: Java Plugin Configuration Parameters
Do NOT name this configuration file sealights.json as this is a reserved file name used by the agent for internal override options.
Add the plugin to your pom.xml
This step adds the SeaLights Maven plugin, configured with the items specified in your config file, to your project's pom.xml . To accomplish this, you will use the command java -jar sl-build-scanner.jar -pom -configfile <config-file-name>
By doing this, you allow the SeaLights Maven plugin to add the necessary SeaLights configuration to automatically complete the configuration, BSID generation, and build scan (steps 2-3 if you were using the implementation steps) as a part of your Maven build.
Minimum Required Parameters for this command:
-configFile- Path to the file containing the JSON configuration you created in Step 2.-workspacepath- The base path to the location of the pom.xml files to update
Command:
java -jar sl-build-scanner.jar -pom -configfile <config-file-name> -workspacepath .What this command does:
Updates your pom.xml with the SeaLights Maven plugin and configuration details.
Creates a backup of your original pom.xml named pom.xml.slback
Output: In the console, you will see [Sealights Build Scanner] - Pom integration was completed. if the command was successful.
Restore your pom.xml (Optional)
IF your workspace is not reset for each run, you will need to restore them at the end of the run. This is generally not a concern if you are implementing this in a CI pipeline.
Use the -restorePom flag to restore your pom.xml to its original content.
Command:
java -jar sl-build-scanner.jar -restorePom -workspacepath .Verification
To confirm that Phase 3 was successful:
Check the console output — Look for messages confirming successful agent startup and scan completion.
Visit the SeaLights Dashboard — Verify that:
Your component's build name appears with the name you have given it in the configuration file
Coverage data is correctly reflected in the test stage
Next Steps
With Continuous Coverage in your CI now in place, you can move to Phase 4: Test Impact Analysis. In Phase 4, you'll begin using TIA to execute the smallest subset of tests — without compromising quality.
Last updated
Was this helpful?

