7.1.4. Importing Java Modules Using a Bazel Workspace

You can import a Bazel workspace as a single module, or multiple modules (per Bazel build file, or per Bazel rule), into an existing Sonargraph system or while creating a new system.

NOTE

For the Sonargraph Bazel import to work, a 'bazelisk' or 'bazel' executable must be found either in Bazel's workspace root directory, or on Sonargraph's path.

Required Bazel version is 2.0.0 minimum.

Supported 'bazel rules' are 'java_binary', 'java_library', and 'java_test', others may be added in the future.

To create a new Sonargraph system from a Bazel workspace as a single module, or multiple modules, use "File""New""System""New Java System Based On Bazel Workspace" .

To import a Bazel workspace as module(s) directly into an already existing Sonargraph system use "File""New""Module""New Java Module(s) Based On Bazel Build Files" .

To import a single Bazel build file as a module directly into an already existing Sonargraph system use "File""New""Module""New Java Module(s) Based On Bazel Workspace" .

Select the location of the Bazel workspace you want to import modules from. Decide first if you want to import the whole workspace as a single module, or as multiple modules. For multiple modules it is possible to use either the bazel output jars, or the directories as Sonargraph root paths.

Importing Java modules using a Bazel workspace
Figure 7.2. Importing Java Modules Using a Bazel workspace

Sonargraph will let you know about content that is already in the software system , empty or irrelevant directory paths and dependencies between modules.