javamavenmaven-3command-line-argumentscustom-headers

Attempting to utilize the Maven argument 'aether.connector.http.headers'


I am using Maven version 3.9.5. I'm attempting to execute a Maven command with the 'aether.connector.http.headers' configuration option to include custom headers in all the HTTP requests made during the Maven process. However, none of the headers I've set are visible in the requests when viewed through the configured proxy. My objective is to incorporate these custom headers into the Maven command without the need to modify settings.xml.

According to the documentation, it is expected to support all configuration options from Maven 3.9 onwards, as outlined in the following link: https://maven.apache.org/resolver/configuration.html

I executed the following command:

mvn install -Daether.connector.http.headers=key:value

Expected Outcome: The HTTP request made during the Maven download dependencies process should include the header key:value.

Actual Outcome: The custom header is not present in the request, as observed in the configured proxy. However, other general headers are present.


Solution

  • As property configuration aether.connector.http.header is a complex type you can not specific it as user property on command line.

    For custom headers you need configure it in your settings.xml, example configuration in settings.xml:

    <settings>
      <servers>
        <server>
          <id>my-server</id>
          <configuration>
            <httpHeaders>
              <property>
                <name>Foo</name>
                <value>Bar</value>
              </property>
            </httpHeaders>
          </configuration>
        </server>
      </servers>
    </settings>
    

    More info: https://maven.apache.org/guides/mini/guide-resolver-transport.html