-
Couldn't load subscription status.
- Fork 76
Add documentation for configuring Maven with a private repository for… #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d0090be
3e60a68
3c3e1c5
4ba3416
2fa4e47
b6050e3
22fa0e5
c9fadaf
e0ae0dd
b522ab3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| ### Configuring Maven to Use a Private Repository for SCIP-JAVA | ||
|
|
||
| #### Overview | ||
| In Sourcegraph, configuring SCIP-JAVA to use a private Maven repository, such as Nexus or Artifactory, is essential when dependencies should not be retrieved from public repositories. This guide covers steps to set up Maven for SCIP-JAVA indexing with a private repository, ensuring secure and consistent dependency resolution. | ||
Rhia2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #### Step 1: Testing the Configuration on a Single Repository | ||
|
|
||
| To test and validate the Maven configuration, start by modifying a single repository’s auto-indexing settings to include a custom `settings.xml` file. | ||
|
||
|
|
||
| 1. **Add Custom Index Job Configuration**: | ||
| - Access the repository’s index settings in Sourcegraph and open the “Raw” configuration panel. | ||
| - Insert the following configuration: | ||
|
|
||
| ```json | ||
| { | ||
| "steps": [], | ||
| "local_steps": [ | ||
| "mkdir -p ~/.m2", | ||
| "echo '<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd\"> <servers> <server> <id>repo</id> <username>$ARTIFACTORY_USER</username> <password>$ARTIFACTORY_PASSWORD</password> </server> </servers> </settings>' > ~/.m2/settings.xml" | ||
| ], | ||
| "root": "", | ||
| "indexer": "sourcegraph/scip-java:latest-snapshot", | ||
Rhia2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "indexer_args": [ | ||
| "scip-java", | ||
| "index", | ||
| "--build-tool=auto" | ||
| ], | ||
| "outfile": "index.scip", | ||
| "requestedEnvVars": [ | ||
| "ARTIFACTORY_USER", | ||
| "ARTIFACTORY_PASSWORD" | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| 2. **Trigger Indexing**: | ||
| - After configuring the repository, navigate to the "Precise Indexes" tab and click "Enqueue" to start the indexing process. | ||
| - Ensure that the environment variables `$ARTIFACTORY_USER` and `$ARTIFACTORY_PASSWORD` are created as Executor Secrets. | ||
Rhia2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| #### Step 2: Automating the Configuration Across All Repositories | ||
|
|
||
| After verifying the configuration on a single repository, automate the setup across all repositories by modifying the inference configuration using a Lua script. | ||
|
|
||
| 1. **Create or Update the Lua Script**: | ||
Rhia2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Go to `site-admin -> Code Graph -> Inference Configuration` on Sourcegraph. | ||
| - Replace or add the following Lua script for SCIP-JAVA indexing with Maven’s `settings.xml` setup: | ||
|
|
||
| ```lua | ||
| local path = require("path") | ||
| local pattern = require("sg.autoindex.patterns") | ||
| local recognizer = require("sg.autoindex.recognizer") | ||
| local patterns = require "internal_patterns" | ||
|
|
||
| local new_steps = { | ||
| 'mkdir -p ~/.m2', | ||
| [[echo "<?xml version=\"1.0\"?><settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"><servers><server><id>repo</id><username>$ARTIFACTORY_USER</username><password>$ARTIFACTORY_PASSWORD</password></server></servers></settings>" > ~/.m2/settings.xml]] | ||
| } | ||
|
|
||
| local new_requested_env_variables = {'ARTIFACTORY_USER', 'ARTIFACTORY_PASSWORD'} | ||
| local java_indexer = require("sg.autoindex.indexes").get "java" | ||
|
|
||
| local custom_java_recognizer = recognizer.new_path_recognizer { | ||
| patterns = { | ||
| pattern.new_path_basename("pom.xml"), | ||
| pattern.new_path_basename("build.gradle"), | ||
| pattern.new_path_basename("build.gradle.kts"), | ||
| }, | ||
| generate = function(api, paths) | ||
| api:register({ | ||
| local_steps = new_steps, | ||
| requested_envvars = new_requested_env_variables, | ||
| root = path.dirname(paths[1]), | ||
| outfile = "index.scip", | ||
| indexer = java_indexer, | ||
| indexer_args = { "scip-java", "index", "--build-tool=auto" } | ||
| }) | ||
| end | ||
| } | ||
|
|
||
| return require("sg.autoindex.config").new({ | ||
| ["custom.java"] = custom_java_recognizer, | ||
| ["sg.java"] = false | ||
| }) | ||
| ``` | ||
Rhia2 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scip-javais not capitalised anywhere in the documentation (afaik), I think it should be consistent with its own documentation: https://sourcegraph.github.io/scip-java/docs/getting-started.htmlUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, Anton! You're right that consistency is important. However, this documentation is primarily focused on the auto-indexing process, with scip-java used as an example to demonstrate how to configure Maven with a private repository. Given that, do you think it would be clearer to frame the doc around auto-indexing in general, rather than focusing specifically on scip-java?
I've updated it to focus on configuring a private Maven repository for auto-indexing. Could you please review the changes and share your thoughts?