ALTERNATIVE: Maven Plugin
Capture coverage on a supported test framework using the SeaLights Maven Plugin
The SeaLights Maven plugin is designed to wrap the entire SeaLights process 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
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
Example Configuration File:
{
"tokenFile": "./sltoken.txt",
"executionType": "testsonly",
"testStage": "Functional Tests",
"labId": "<test-env-id>",
"runFunctionalTests": true
}Minimum Required Parameters for this configuration:
tokenfile- Your SeaLights agent token or path to token fileexecutionType- Set to "testsonly"testStage- A label for the type of tests being run (e.g., "Functional Tests", "Integration Tests", "E2E Tests"). This will be used when displaying the test results in your SeaLights reports.labId- A unique name representing the environment in which your AUT was deployed (and against which you are testing). This MUST match the Lab ID from Phase 1.runFunctionalTests- Set to "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> -workspacepath <path>
By doing this, you allow the SeaLights Maven plugin to add the necessary SeaLights configuration to run with your test runner, without needing to update the JVM options at runtime.
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 /path/to/config/file.json \
-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.
What Happens When Your Test Runner Starts?
The SeaLights agent rides along with your test runner to send metadata about the tests you're running to the SeaLights Backend. After your test execution is completed, SeaLights will automatically show you the percentage of code covered by this test run.
Verification
To confirm Phase 2 (ALTERNATIVE) was successful:
Check the console output — Look for messages confirming successful agent startup and scan completion.
Visit the SeaLights Dashboard — Verify that:
Your new test stage appears in the dashboard under your component
Coverage data begins appearing under the new test stage
If this test stage reflects coverage under your component, Phase 2 is complete!
Next Steps
With advanced coverage analytics in place, you're ready to move on to Phase 3: Continuous Coverage. In Phase 3, you'll integrate SeaLights into your CI pipeline for continuous, up-to-date visibility into build coverage.
Last updated
Was this helpful?

