claudelesniewski opened a new pull request, #11758: URL: https://github.com/apache/maven/pull/11758
## Description This PR adds support for configuring HTTP/HTTPS proxies via environment variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY) in Maven's repository system session factory. This follows standard Unix/curl conventions for proxy configuration. ## Changes ### Main Implementation (`DefaultRepositorySystemSessionFactory.java`) - Added `addProxiesFromEnvironment()` method to parse proxy settings from environment variables - Added `getEnvVar()` helper to retrieve environment variables with fallback from uppercase to lowercase keys (Unix convention) - Added `addProxyFromUrl()` helper to parse proxy URLs and extract host, port, and optional authentication credentials - Environment variable proxies are only applied if not already covered by settings.xml proxies (settings take precedence) - Supports NO_PROXY/no_proxy for specifying hosts that should bypass the proxy - Handles default ports (80 for HTTP, 443 for HTTPS) when not specified in the proxy URL - Includes proper error handling and logging for invalid proxy URLs ### Tests (`DefaultRepositorySystemSessionFactoryTest.java`) Added three comprehensive test cases: 1. **`proxyFromEnvVarsTest()`** - Verifies that HTTP and HTTPS proxies are correctly configured from environment variables 2. **`settingsProxyTakesPrecedenceOverEnvVarsTest()`** - Confirms that settings.xml proxies take precedence over environment variables, while env vars fill in for uncovered protocols 3. **`proxyFromEnvVarsViaEnvironmentUtilsTest()`** - End-to-end test using real environment variables (conditionally skipped if HTTPS_PROXY is not set) ## Behavior - Environment variable proxies are applied only for protocols not already configured in settings.xml - Supports standard environment variable names: HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY (and lowercase variants) - Properly parses proxy URLs including optional username:password authentication - NO_PROXY comma-separated list is converted to Maven's pipe-separated nonProxyHosts format - Invalid proxy URLs are logged as warnings and skipped ## Testing All changes are covered by unit tests that verify: - Proxy configuration from environment variables works correctly - Settings proxies take precedence over environment variables - Real environment variables are properly read and applied https://claude.ai/code/session_01Fsmh9ieCCeuLUt45Fn7scs -- 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]
