jgneff commented on issue #11011: URL: https://github.com/apache/maven/issues/11011#issuecomment-4012492763
> Have you tried the property `aether.connector.http.useSystemProperties` from documentation [1]? Thank you, Tamás! That solved the [problem I encountered](https://answers.launchpad.net/launchpad-buildd/+question/823729) building Maven 3.9.13 on the Ubuntu Launchpad build farm. Although the [Artifact Resolver](https://maven.apache.org/resolver-archives/resolver-LATEST-1.x/configuration.html) documentation states, "This mode is not recommended," I have not found a way to make this work using the recommended way of [configuring a proxy](https://maven.apache.org/guides/mini/guide-proxies.html). See below for details. ### Using System Properties - Works The Launchpad build farm provides its proxy settings in the environment variables `http_proxy` and `https_proxy`. The most direct way to pass these settings to Maven is to parse their values and get them into the corresponding Java system properties: ```Shell # Gets the host and port from a proxy URL # $1 = the proxy URL, such as "http://10.10.10.1:8222/" getproxy () { # Parses URL with Bash or Dash shell parameter expansion tail=${1#http*://} head=${tail%%/*} host=${head%:*} port=${head##*:} } # Sets Java networking properties when using a proxy server proxies="-Daether.connector.http.useSystemProperties=true" if [ -n "${http_proxy:-}" ]; then getproxy "$http_proxy" proxies="$proxies -Dhttp.proxyHost=$host -Dhttp.proxyPort=$port" fi if [ -n "${https_proxy:-}" ]; then getproxy "$https_proxy" proxies="$proxies -Dhttps.proxyHost=$host -Dhttps.proxyPort=$port" fi # Builds Maven export MAVEN_HOME="$CRAFT_STAGE/apache-maven-3.9.12" export MAVEN_OPTS="$proxies" "$MAVEN_HOME/bin/mvn" --batch-mode --strict-checksums \ --define distributionTargetDir="$CRAFT_PART_INSTALL/maven" \ --quiet --show-version package ``` After adding the property `aether.connector.http.useSystemProperties=true`, the five HTTPS requests made by Maven during the build now go through the Launchpad proxy server, as required: ``` :: + MAVEN_OPTS='-Daether.connector.http.useSystemProperties=true -Dhttp.proxyHost=10.10.10.1 -Dhttp.proxyPort=8222 -Dhttps.proxyHost=10.10.10.1 -Dhttps.proxyPort=8222' :: + /build/strictly-maven/stage/apache-maven-3.9.12/bin/mvn --batch-mode --strict-checksums --define distributionTargetDir=/build/strictly-maven/parts/mvn/install/maven --quiet --show-version package :: Apache Maven 3.9.12 (848fbb4bf2d427b72bdb2471c22fced7ebd9a7a1) :: Maven home: /build/strictly-maven/stage/apache-maven-3.9.12 :: Java version: 17.0.18, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64 :: Default locale: en, platform encoding: UTF-8 :: OS name: "linux", version: "6.8.0-101-generic", arch: "amd64", family: "unix" :: + cp /build/strictly-maven/conf/settings-global.xml /build/strictly-maven/parts/mvn/install/maven/conf/settings.xml [05/Mar/2026:17:26:33 +0000] "CONNECT repo.maven.apache.org:443 HTTP/1.1" 200 46893516 "-" "Apache-Maven/3.9.12 (Java 17.0.18; Linux 6.8.0-101-generic)" [05/Mar/2026:17:26:33 +0000] "CONNECT repo.maven.apache.org:443 HTTP/1.1" 200 19725553 "-" "Apache-Maven/3.9.12 (Java 17.0.18; Linux 6.8.0-101-generic)" [05/Mar/2026:17:26:33 +0000] "CONNECT repo.maven.apache.org:443 HTTP/1.1" 200 21162014 "-" "Apache-Maven/3.9.12 (Java 17.0.18; Linux 6.8.0-101-generic)" [05/Mar/2026:17:26:33 +0000] "CONNECT repo.maven.apache.org:443 HTTP/1.1" 200 22801397 "-" "Apache-Maven/3.9.12 (Java 17.0.18; Linux 6.8.0-101-generic)" [05/Mar/2026:17:26:33 +0000] "CONNECT repo.maven.apache.org:443 HTTP/1.1" 200 25469084 "-" "Apache-Maven/3.9.12 (Java 17.0.18; Linux 6.8.0-101-generic)" ``` ### Using *settings.xml* - Fails I have not found a way to get the host and port of the proxy servers into the *settings.xml* file in a dynamic way that works. If I hard-code the values in the file, it works fine. But if I try to use Java system properties or Maven user properties in the file, they are not recognized. I've tried setting an HTTP proxy and an HTTPS proxy, and I've tried using MAVEN_OPTS and MAVEN_ARGS, but nothing works. Below is the shell script: ```Shell # Gets the host and port from a proxy URL # $1 = the proxy URL, such as "http://10.10.10.1:8222/" getproxy () { # Parses URL with Bash or Dash shell parameter expansion tail=${1#http*://} head=${tail%%/*} host=${head%:*} port=${head##*:} } # Sets Java networking properties when using a proxy server proxies="-Dproxy.active=false" if [ -n "${https_proxy:-}" ]; then proxies="-Dproxy.active=true" getproxy "$https_proxy" proxies="$proxies -Dhttps.proxyHost=$host -Dhttps.proxyPort=$port" fi # Builds Maven export MAVEN_HOME="$CRAFT_STAGE/apache-maven-3.9.12" export MAVEN_OPTS="$proxies" "$MAVEN_HOME/bin/mvn" --batch-mode --strict-checksums \ --define distributionTargetDir="$CRAFT_PART_INSTALL/maven" \ --quiet --settings "$CRAFT_PROJECT_DIR/conf/settings-build.xml" \ --show-version package ``` And below is the *settings.xml* file I'm using: ```XML <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd"> <proxies> <proxy> <active>${proxy.active}</active> <protocol>https</protocol> <host>${https.proxyHost}</host> <port>${https.proxyPort}</port> </proxy> </proxies> </settings> ``` Yet the build fails with an error indicating that it's not using the proxy servers: ``` :: + MAVEN_OPTS='-Dproxy.active=true -Dhttps.proxyHost=10.10.10.1 -Dhttps.proxyPort=8222' :: + /build/snapcraft-strictly-maven-8fd0a4626b0abe4c1ea2dab99328bc4c/stage/apache-maven-3.9.12/bin/mvn --batch-mode --strict-checksums --define distributionTargetDir=/build/snapcraft-strictly-maven-8fd0a4626b0abe4c1ea2dab99328bc4c/parts/mvn/install/maven --quiet --settings /build/snapcraft-strictly-maven-8fd0a4626b0abe4c1ea2dab99328bc4c/conf/settings-build.xml --show-version package :: Apache Maven 3.9.12 (848fbb4bf2d427b72bdb2471c22fced7ebd9a7a1) :: Maven home: /build/snapcraft-strictly-maven-8fd0a4626b0abe4c1ea2dab99328bc4c/stage/apache-maven-3.9.12 :: Java version: 17.0.18, vendor: Ubuntu, runtime: /usr/lib/jvm/java-17-openjdk-amd64 :: Default locale: en, platform encoding: UTF-8 :: OS name: "linux", version: "6.8.0-101-generic", arch: "amd64", family: "unix" :: [ERROR] [ERROR] Some problems were encountered while processing the POMs: :: [FATAL] Non-resolvable parent POM for org.apache.maven:maven:3.9.13: The following artifacts could not be resolved: org.apache.maven:maven-parent:pom:47 (absent): Could not transfer artifact org.apache.maven:maven-parent:pom:47 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Name or service not known and 'parent.relativePath' points at no local POM @ line 23, column 11 :: @ :: [ERROR] The build could not read 1 project -> [Help 1] :: [ERROR] :: [ERROR] The project org.apache.maven:maven:3.9.13 (/build/snapcraft-strictly-maven-8fd0a4626b0abe4c1ea2dab99328bc4c/parts/mvn/build/pom.xml) has 1 error :: [ERROR] Non-resolvable parent POM for org.apache.maven:maven:3.9.13: The following artifacts could not be resolved: org.apache.maven:maven-parent:pom:47 (absent): Could not transfer artifact org.apache.maven:maven-parent:pom:47 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: Name or service not known and 'parent.relativePath' points at no local POM @ line 23, column 11: Unknown host repo.maven.apache.org: Name or service not known -> [Help 2] ``` Any idea what I'm doing wrong? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
