JVM dependency integration with Sourcegraph
You can use Sourcegraph with JVM dependencies from any Maven repository, including Maven Central, Sonatype, or Artifactory.
This integration makes it possible to search and navigate through the source code of the JDK (Java standard library) or published Java, Scala, and Kotlin libraries (for example, com.google.guava:guava:27.0-jre
).
Feature | Supported? |
---|---|
Repository syncing | ✅ |
Credentials | ✅ |
Repository permissions | ❌ |
Multiple JVM dependency code hosts | ❌ |
Repository syncing
There are two ways to sync JVM dependency repositories.
- LSIF (recommended): run
lsif-java
against your JVM codebase and upload the generated index to Sourcegraph using the src-cli commandsrc lsif upload
. Sourcegraph automatically synchronizes JVM dependency repositories based on the dependencies that are discovered bylsif-java
. - Code host configuration: manually list dependencies in the
"dependencies"
section of the JSON configuration when creating the JVM dependency code host. This method can be useful to verify that the credentials are picked up correctly without having to upload LSIF.
Credentials
Sourcegraph uses Coursier to resolve JVM dependencies.
Use the "credentials"
section of the JSON configuration to provide usernames and passwords to access your Maven repository. See the Coursier documentation about inline credentials to learn more about how to format the "credentials"
configuration.
Repository permissions
⚠️ JVM dependency repositories are visible by all users of the Sourcegraph instance.
Multiple JVM dependency code hosts
⚠️ It's only possible to create one JVM dependency code host for each Sourcegraph instance. See the issue sourcegraph#32461 for more details about this limitation. In most situations, it's possible to work around this limitation by configurating multiple Maven repositories to the same JVM dependency code host.