Skip to content

Commit b123478

Browse files
committed
Add minor documentation for Bazel, fixes #445
1 parent 75204f2 commit b123478

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77
| Manual configuration | https://sourcegraph.github.io/scip-java/docs/manual-configuration.html |
88
| Contributing | https://sourcegraph.github.io/scip-java/docs/contributing.html |
99
| Design | https://sourcegraph.github.io/scip-java/docs/design.html |
10-

docs/getting-started.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ free to subscribe to the tracking issues to receive updates on your build tool.
241241
| Gradle |||| |
242242
| sbt ||| n/a | |
243243
| Ant |||| [sourcegraph/scip-java#305](https://github.com/sourcegraph/scip-java/issues/305) |
244-
| Bazel | | || [sourcegraph/scip-java#88](https://github.com/sourcegraph/scip-java/issues/88) |
244+
| Bazel | | || |
245245
| Buck |||| [sourcegraph/scip-java#99](https://github.com/sourcegraph/scip-java/issues/99) |
246246
| Mill |||| [sourcegraph/scip-java#306](https://github.com/sourcegraph/scip-java/issues/306) |
247247

@@ -299,3 +299,23 @@ projects, with the following caveats:
299299
| ------------- | --------- | ----------------------- |
300300
| sbt <v0.13.17 || Upgrade to sbt v0.13.17 |
301301

302+
### Bazel
303+
304+
Bazel is supported by scip-java but it requires custom configuration to work
305+
correctly. Note that the `scip-java index` command does not automatically index
306+
Bazel builds.
307+
308+
The Bazel integration for scip-java is specifically designed to be compatible
309+
with the Bazel build cache to enable incremental indexing. To achieve this,
310+
scip-java must be configured in `WORKSPACE` and `BUILD` files. The scip-java
311+
repository contains an example for how to configure everything.
312+
313+
- [WORKSPACE](https://github.com/sourcegraph/scip-java/blob/main/examples/bazel-example/WORKSPACE):
314+
adds the required dependencies to be able to run scip-java itself.
315+
- [BUILD](https://github.com/sourcegraph/scip-java/blob/main/examples/bazel-example/src/main/java/example/BUILD):
316+
configured `java_library` and `java_binary` targets to be indexed with
317+
scip-java.
318+
319+
Don't hesitate to open an issue in the
320+
[scip-java repository](https://github.com/sourcegraph/scip-java) if you have any
321+
questions about using scip-java with Bazel builds.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.sourcegraph.scip_java.buildtools
2+
3+
import java.nio.file.Files
4+
5+
import com.sourcegraph.scip_java.commands.IndexCommand
6+
7+
class BazelBuildTool(index: IndexCommand) extends BuildTool("Bazel", index) {
8+
9+
override def usedInCurrentDirectory(): Boolean = {
10+
Files.isRegularFile(index.workingDirectory.resolve("WORKSPACE"))
11+
}
12+
13+
override def generateScip(): Int = {
14+
index
15+
.app
16+
.reporter
17+
.error(
18+
"The `scip-java index` command does not work with Bazel builds because Bazel " +
19+
"requires custom configuration to be added to WORKSPACE and BUILD files. " +
20+
"The scip-java repository contains an example WORKSPACE file to demonstrate " +
21+
"how to use scip-java with Bazel https://github.com/sourcegraph/scip-java/blob/main/examples/bazel-example/WORKSPACE"
22+
)
23+
1
24+
}
25+
}

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/BuildTool.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ abstract class BuildTool(val name: String, index: IndexCommand) {
2020
object BuildTool {
2121
def all(index: IndexCommand): List[BuildTool] =
2222
List(
23+
new BazelBuildTool(index),
2324
new GradleBuildTool(index),
2425
new MavenBuildTool(index),
2526
new ScipBuildTool(index),

0 commit comments

Comments
 (0)