Skip to content

Commit d0090be

Browse files
authored
Add documentation for configuring Maven with a private repository for SCIP-JAVA private-maven-repository-configuration-scip-java.mdx
- Added a new Markdown file detailing the steps to configure Maven to use a private Nexus or Artifactory repository for SCIP-JAVA indexing. - Includes guidance for single repository testing and automated configuration across multiple repositories via Sourcegraph's Lua inference script. - Docs placed under the Code Navigation section to aid users in secure dependency management for SCIP-JAVA.
1 parent 5e6dbff commit d0090be

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
### Configuring Maven to Use a Private Repository for SCIP-JAVA
2+
3+
#### Overview
4+
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.
5+
6+
#### Step 1: Testing the Configuration on a Single Repository
7+
8+
To test and validate the Maven configuration, start by modifying a single repository’s auto-indexing settings to include a custom `settings.xml` file.
9+
10+
1. **Add Custom Index Job Configuration**:
11+
- Access the repository’s index settings in Sourcegraph and open the “Raw” configuration panel.
12+
- Insert the following configuration:
13+
14+
```json
15+
{
16+
"steps": [],
17+
"local_steps": [
18+
"mkdir -p ~/.m2",
19+
"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"
20+
],
21+
"root": "",
22+
"indexer": "sourcegraph/scip-java:latest-snapshot",
23+
"indexer_args": [
24+
"scip-java",
25+
"index",
26+
"--build-tool=auto"
27+
],
28+
"outfile": "index.scip",
29+
"requestedEnvVars": [
30+
"ARTIFACTORY_USER",
31+
"ARTIFACTORY_PASSWORD"
32+
]
33+
}
34+
```
35+
36+
2. **Trigger Indexing**:
37+
- After configuring the repository, navigate to the "Precise Indexes" tab and click "Enqueue" to start the indexing process.
38+
- Ensure that the environment variables `$ARTIFACTORY_USER` and `$ARTIFACTORY_PASSWORD` are created as Executor Secrets.
39+
40+
41+
#### Step 2: Automating the Configuration Across All Repositories
42+
43+
After verifying the configuration on a single repository, automate the setup across all repositories by modifying the inference configuration using a Lua script.
44+
45+
1. **Create or Update the Lua Script**:
46+
- Go to `site-admin -> Code Graph -> Inference Configuration` on Sourcegraph.
47+
- Replace or add the following Lua script for SCIP-JAVA indexing with Maven’s `settings.xml` setup:
48+
49+
```lua
50+
local path = require("path")
51+
local pattern = require("sg.autoindex.patterns")
52+
local recognizer = require("sg.autoindex.recognizer")
53+
local patterns = require "internal_patterns"
54+
55+
local new_steps = {
56+
'mkdir -p ~/.m2',
57+
[[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]]
58+
}
59+
60+
local new_requested_env_variables = {'ARTIFACTORY_USER', 'ARTIFACTORY_PASSWORD'}
61+
local java_indexer = require("sg.autoindex.indexes").get "java"
62+
63+
local custom_java_recognizer = recognizer.new_path_recognizer {
64+
patterns = {
65+
pattern.new_path_basename("pom.xml"),
66+
pattern.new_path_basename("build.gradle"),
67+
pattern.new_path_basename("build.gradle.kts"),
68+
},
69+
generate = function(api, paths)
70+
api:register({
71+
local_steps = new_steps,
72+
requested_envvars = new_requested_env_variables,
73+
root = path.dirname(paths[1]),
74+
outfile = "index.scip",
75+
indexer = java_indexer,
76+
indexer_args = { "scip-java", "index", "--build-tool=auto" }
77+
})
78+
end
79+
}
80+
81+
return require("sg.autoindex.config").new({
82+
["custom.java"] = custom_java_recognizer,
83+
["sg.java"] = false
84+
})
85+
```

0 commit comments

Comments
 (0)