# 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 -workspacepath "/path/to/war/files" -fi "*.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 `-r` flag.

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

```sh
java -jar sl-build-scanner.jar -scan -tokenfile /path/to/sltoken.txt -buildsessionidfile buildSessionId.txt -workspacepath "/path/to/war/files" -fi "*.class" -r
```

{% 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 -workspacepath "/path/to/war/files" -fi "*.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 [#inlineextension-scanning-a-build](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/command-reference#inlineextension-scanning-a-build "mention") for full parameter details
{% endhint %}
