Skip to content

Commit 450d402

Browse files
authored
Merge pull request #312 from olafurpg/xrepo-docs
Add docs for how to manually enable cross-repository navigation
2 parents 78da9d4 + 97b982c commit 450d402

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

docs/manual-configuration.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ compiler plugin. To do this you need to explicitly configure two directories:
6767
this directory.
6868
- `-targetroot:PATH`: the absolute path to the directory where to generate
6969
SemanticDB file. This directory can be anywhere on your file system.
70-
Alternatively, pass in `-targetroot:javac-classes-directory`
71-
for the plugin to automatically use the `javac` output directory.
70+
Alternatively, pass in `-targetroot:javac-classes-directory` for the plugin to
71+
automatically use the `javac` output directory.
7272

7373
If you're using Gradle.
7474

@@ -150,3 +150,41 @@ into LSIF.
150150
❯ file dump.lsif
151151
dump.lsif: JSON data
152152
```
153+
154+
## Step 5 (optional): Enable cross-repository navigation
155+
156+
By default, the `dump.lsif` file only enables navigation within the local
157+
repository. You can optionally enable cross-repository navigation by creating
158+
one of the following files in the SemanticDB _targetroot_ directory (the path in
159+
`-Xplugin:semanticdb -targeroot:PATH`).
160+
161+
- `javacopts.txt`: line-separated list of Java compiler options that got passed
162+
to the compiler. For example,
163+
```sh
164+
$ cat $TARGETROOT/javacopts.txt
165+
-Xlint
166+
-classpath
167+
-path/to/dependency1.jar:/path/to/dependency2.jar
168+
-d
169+
/path/to/classes/directory
170+
/path/to/com/example/Main.java
171+
```
172+
The `javacopts.txt` file format can only be used if the jars on the dependency
173+
classpath have sibling `.pom` files. In some build tools like Gradle, the POM
174+
files are not siblings to the jars on the classpath so the `javacopts.txt`
175+
format cannot be used.
176+
- `dependencies.txt`: a tab-separated values file where the columns are: group
177+
ID, artifact ID, version and jar path. For example,
178+
```sh
179+
$ cat $TARGETROOT/dependencies.txt
180+
junit junit 4.13.2 /path/to/junit.jar
181+
org.hamcrest hamcrest-core 1.3 /path/to/hamcrest-core.jar
182+
```
183+
The `dependencies.txt` format is used by lsif-java to map symbols such as
184+
`org.junit.Assert` to Maven co-ordinates like `junit:junit:4.13.2`. As long as
185+
your Sourcegraph instance has another repository that defines that symbol, the
186+
cross-repository navigation should succeed. Only jar files are supported at
187+
the moment, classes directories are ignored.
188+
189+
Cross-repository navigation is a feature that allows "goto definition" and "find
190+
references" to show results from multiple repositories.

0 commit comments

Comments
 (0)