> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/default-usage-cli/scanning-a-build.md).

# Scanning a build

In order to collect coverage information SeaLights agents need to first scan the binary files for the build information.

It can be the `*.class`, `*.jar` or even the `*.war` files.

## Scanning a build (single module) <a href="#scanning-a-build-single-module" id="scanning-a-build-single-module"></a>

Scanning a build in Java is done using the Java Build scanner with the -scan flag for files located in workspace folder only.

{% code overflow="wrap" lineNumbers="true" %}

```sh
java -jar sl-build-scanner.jar scan --tokenFile /path/to/sltoken.txt --buildSessionIdFile buildSessionId.txt --scanDir "/path/to/war/files" --includeFiles "*.war"
```

{% endcode %}

Scanning a build in Java for all files located in workspace folder and it's subdirectories, is done using the Java Build scanner with the `scan` flag and `--recursive` flag.

{% code overflow="wrap" lineNumbers="true" %}

```sh
java -jar sl-build-scanner.jar scan --tokenFile /path/to/sltoken.txt --buildSessionIdFile buildSessionId.txt --scanDir "/path/to/war/files" --includeFiles "*.class" --recursive
```

{% endcode %}

## Scanning multi modules <a href="#scanning-multi-modules" id="scanning-multi-modules"></a>

If you want to report separate parts of the application as separate modules, you can do so with the `--moduleName` option.

{% code overflow="wrap" lineNumbers="true" %}

```sh
java -jar sl-build-scanner.jar scan --tokenFile /path/to/sltoken.txt --buildSessionIdFile buildSessionId.txt --scanDir "/path/to/war/files" --includeFiles "*.war" --moduleName "moduleName"
```

{% endcode %}

{% hint style="danger" %}
It is important to always use the exact same module names each time you report a new build.
{% endhint %}

\
When you finish reporting all the modules, you need to send the event with the `buildend` option and either the `--ok` or `--failed` depending on the result of your build process.

{% code overflow="wrap" lineNumbers="true" %}

```sh
java -jar sl-build-scanner.jar buildend --ok --tokenFile sltoken.txt --buildSessionIdFile buildSessionId.txt
```

{% endcode %}

{% hint style="info" %}
See [Command Reference](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/command-reference.md#inlineextension-scanning-a-build) for full parameter details
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/default-usage-cli/scanning-a-build.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
