Home

Awesome

Bazel Maven Proxy

A local (read-only) proxy for Bazel to access Maven resources behind a secure repository or from the local Maven repo

Features

Getting Started

Different JDK

In case you need to use a different JDK you can create a .bazelrc-local file. Please have a look at .bazelrc for further instructions.

Command Line Arguments

Usage: bazel-maven-proxy [--local-maven-repository=PATH]
                         [--unsecure-port=<unsecurePort>]
                         [-c=PROXY-CONFIG-YAML] [-p=<port>]
                         [-s=MAVEN-SETTINGS-XML]
Starts the Bazel Maven Proxy
  -c, --config-file=PROXY-CONFIG-YAML
                      proxy configuration file with (additional) repositories to
                        proxy, i.e. path to proxy-config.yaml
  -h, --help          Show this help message and exit.
      --host=<host>   host name to listen on (default is 127.0.0.1, i.e. only
                        local connections allowed; use 0.0.0.0 to listen on all
                        interfaces)
      --local-maven-repository=PATH
                      path to Maven's local repository (default: ~/.
                        m2/repository/)
  -p, --port=<port>   port to listen on (HTTP/2 and HTTP 1.1 with self-sign
                        'localhost' certificate)
  -s, --maven-settings=MAVEN-SETTINGS-XML
                      path to Maven's settings.xml to read repositories and
                        authentication information (default is ~/.
                        m2/settings.xml)
      --unsecure-port=<unsecurePort>
                      non-secure (plain HTTP) port to listen on (default is none, set to >0 to
                        enable)
  -V, --version       Print version information and exit.

How to Use

Please ensure that your ~/.m2/settings.xml has an entry for your repository like this:

  ...
  <servers>
    <server>
      <id>mynexus</id>
      <username>...</username>
      <password>...</password>
    </server>
    <server>
      <id>central</id>
      <username>...</username>
      <password>...</password>
    </server>
  </servers>
  ...

  <profiles>
    <profile>
      <id>mynexus</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://my-central-mirror.internal.network.com/..</url>
        </repository>
        <repository>
          <id>mynexus</id>
          <url>https://my-nexus-repo.internal.network.com/..</url>
        </repository>
      </repositories>
      ...
    </profile>
  </profiles>

Then in Bazel (or anywhere else) you can refer to these as http(s)://localhost:<port>/maven/mynexus/.. and http(s)://localhost:<port>/maven/central/...

Alternatively to (or in addition to) ~/.m2/settings.xml one can also provide a YAML configuration file. See an example here for syntax.