@@ -328,9 +328,8 @@ projects, with the following caveats:
328328
329329### Bazel
330330
331- Bazel is supported by scip-java but it requires custom configuration to work
332- correctly. Note that the ` scip-java index ` command does not automatically index
333- Bazel builds.
331+ Bazel is supported by scip-java, but it requires custom configuration to work
332+ correctly. The ` scip-java index ` command does not automatically index Bazel builds.
334333
335334The Bazel integration for scip-java is specifically designed to be compatible
336335with the Bazel build cache to enable incremental indexing. To achieve this,
@@ -343,6 +342,38 @@ repository contains an example for how to configure everything.
343342 configured ` java_library ` and ` java_binary ` targets to be indexed with
344343 scip-java.
345344
345+ Once configured, build the codebase with the SemanticDB compiler plugin.
346+ ``` sh
347+ bazel build //... --@scip_java//semanticdb-javac:enabled=true
348+ ```
349+
350+ Next, run the following command to generate the SCIP index (` index.scip ` ).
351+
352+ ```
353+ bazel run @scip_java//scip-semanticdb:bazel -- --sourceroot $PWD
354+
355+ # (optional) Validate that SemanticDB files were generated.
356+ # The command below works for the `examples/bazel-example` directory in the sourcegraph/scip-java repository.
357+ ❯ jar tf bazel-bin/src/main/java/example/libexample.jar | grep semanticdb$
358+ META-INF/semanticdb/src/main/java/example/Example.java.semanticdb
359+ ```
360+
361+ Finally, run the following commands to upload the SCIP index to Sourcegraph.
362+
363+ ```
364+ # 1. Install src
365+ npm install -g @sourcegraph/src # Or yarn global add @sourcegraph/src
366+
367+ # 2. Authenticate with Sourcegraph
368+ export SRC_ACCESS_TOKEN=sgp_YOUR_ACCESS_TOKEN
369+ export SRC_ENDPOINT=https://sourcegraph.example.com
370+ src login # validate the token authenticates correctly
371+
372+ # 3. Upload SCIP index to Sourcegraph
373+ src code-intel upload # requires index.scip file to exist
374+ ```
375+
376+
346377Don't hesitate to open an issue in the
347378[ scip-java repository] ( https://github.com/sourcegraph/scip-java ) if you have any
348379questions about using scip-java with Bazel builds.
0 commit comments