Skip to content

Commit

Permalink
Increased the number of repos to 10 and added optional REPO_DEFAULT.
Browse files Browse the repository at this point in the history
  • Loading branch information
raehalme committed Nov 9, 2017
1 parent 76d1161 commit 1f49a1d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
63 changes: 63 additions & 0 deletions README.md
Expand Up @@ -8,3 +8,66 @@ The proxy is intended to be run close to the build environment improving
build performance by avoiding obsolete network requests for artifacts known to
be located on a specific repository. It's a pity that Maven does not support
this out of the box.


Quick Setup
-----------

1. Install the proxy with npm: `sudo npm i maven-routing-proxy -g`

2. Configure repositories in `config.json`.

3. Start the proxy with `mvnproxy`.

4. Configure Maven to use mirror at `http://localhost:8181`.

5. Profit!!


Configuration
-------------

The proxy reads `config.json` from the work directory (where the proxy is
started). The configuration file contains the list of repositories where to
look for dependencies with their corresponding groupIds, and also defines
the default repository to use.

The following example adds three repositories there the first two are used only
when the groupId of the dependency starts with the list of values specified by
`include`. The final, default, is used when none of the previous definitions
match the dependency groupId.

```
{
"repositories": {
"https://example.com/nexus/content/repositories/releases": {
"username": "%NEXUS_USERNAME%",
"password": "%NEXUS_PASSWORD%",
"include": [ "com.example", "org.example" ]
},
"https://repo.example.net/maven2": {
"include": [ "net.example" ]
},
"default": "https://repo.maven.apache.org/maven2"
}
}
```

The first example uses environment variables NEXUS_USERNAME and NEXUS_PASSWORD
to configure credentials. At the moment only Basic authentication is supported
for authentication but that is sufficient with at least
[Nexus](http://www.sonatype.org/nexus/).

The credentials are optional and the second example does not specify any.

Finally `"default"` is used to configure the default repository to which the
request is directed in case none of the previous repositories match the
dependency groupId.


Running the Proxy
-----------------


Configuring Maven
-----------------
7 changes: 6 additions & 1 deletion run.sh
Expand Up @@ -27,7 +27,12 @@ appendRepository "${REPO2_URL}" "${REPO2_USERNAME}" "${REPO2_PASSWORD}" "${REPO2
appendRepository "${REPO3_URL}" "${REPO3_USERNAME}" "${REPO3_PASSWORD}" "${REPO3_INCLUDES}"
appendRepository "${REPO4_URL}" "${REPO4_USERNAME}" "${REPO4_PASSWORD}" "${REPO4_INCLUDES}"
appendRepository "${REPO5_URL}" "${REPO5_USERNAME}" "${REPO5_PASSWORD}" "${REPO5_INCLUDES}"
appendRepository "${REPO6_URL}" "${REPO6_USERNAME}" "${REPO6_PASSWORD}" "${REPO6_INCLUDES}"
appendRepository "${REPO7_URL}" "${REPO7_USERNAME}" "${REPO7_PASSWORD}" "${REPO7_INCLUDES}"
appendRepository "${REPO8_URL}" "${REPO8_USERNAME}" "${REPO8_PASSWORD}" "${REPO8_INCLUDES}"
appendRepository "${REPO9_URL}" "${REPO9_USERNAME}" "${REPO9_PASSWORD}" "${REPO9_INCLUDES}"
appendRepository "${REPO10_URL}" "${REPO10_USERNAME}" "${REPO10_PASSWORD}" "${REPO10_INCLUDES}"

echo "\"default\":\"https://repo.maven.apache.org/maven2\"}}" >> config.json
echo "\"default\":\"${REPO_DEFAULT:-https://repo.maven.apache.org/maven2}\"}}" >> config.json

npm run start

0 comments on commit 1f49a1d

Please sign in to comment.