JVM dependencies
Site admins can sync JVM dependencies from any Maven repository, including Maven Central, Sonatype, or Artifactory, to their Sourcegraph instance so that users can search and navigate the repositories.
To add JVM dependencies to Sourcegraph you need to setup a JVM dependencies code host:
- As site admin: go to Site admin > Site configuration and enable the experimental feature by adding:
{"experimentalFeatures": {"jvmPackages": "enabled"} }
- As site admin: go to Site admin > Manage code hosts
- Select JVM Dependencies.
- Configure the connection by following the instructions above the text field. Additional fields can be added using Cmd/Ctrl+Space for auto-completion. See the configuration documentation below.
- Press Add repositories.
Repository syncing
There are two ways to sync JVM dependency repositories.
- Indexing (recommended): run
scip-java
against your JVM codebase and upload the generated index to Sourcegraph using the src-cli commandsrc code-intel upload
. This is usually setup to run in a CI pipeline. Sourcegraph automatically synchronizes JVM dependency repositories based on the dependencies that are discovered byscip-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 an index.
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, or the example displayed at the bottom of the page.
Rate limiting
By default, requests to the JVM dependency code host will be rate-limited based on a default internal limit. (source)
To manually set the value, add the following to your code host configuration:
"rateLimit": { "enabled": true, "requestsPerHour": 600 }
where the requestsPerHour
field is set based on your requirements.
Not recommended: Rate-limiting can be turned off entirely as well. This increases the risk of overloading the code host.
"rateLimit": { "enabled": false }
Configuration
JVM dependencies code host connections support the following configuration options, which are specified in the JSON editor in the site admin "Manage code hosts" area.
admin/external_service/jvm-packages.schema.json
{ // Configuration for resolving from Maven repositories. "maven": { "credentials": "", "dependencies": [], "rateLimit": { "enabled": true, "requestsPerHour": 7200 }, "repositories": [] } // Other example values: // - { // "maven": { // "credentials": "jfrog.frogger.com myuser:supersecret\njfrogmirror.frogger.com(basicauth realm) frog:detective", // "dependencies": [ // "com.sourcegraph:semanticdb-kotlinc:0.1.1" // ], // "rateLimit": { // "enabled": true, // "requestsPerHour": 3600 // }, // "repositories": [ // "central", // "http://repo.extendedclip.com/content/repositories/public/" // ] // } // } }