You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "elharo (via GitHub)" <gi...@apache.org> on 2026/08/06 12:01:28 UTC

[PR] Discover global settings from Maven home env vars and properties (#168) [maven-resolver-ant-tasks]

elharo opened a new pull request, #177:
URL: https://github.com/apache/maven-resolver-ant-tasks/pull/177

   Fixes #168
   
   ## Summary
   
   `AetherUtils.getMavenHome()` only read the `maven.home` Ant property, which is almost never set in a plain Ant build. Global mirrors, proxies, and server credentials from `settings.xml` were therefore silently ignored. `findGlobalSettings()` also gave `ANT_HOME/etc/settings.xml` precedence over the Maven `conf/settings.xml`, which is likely inverted.
   
   ## Changes
   
   - `AetherUtils.getMavenHome()` now resolves the Maven home in order: `maven.home` Ant property, `maven.home` system property, `MAVEN_HOME` environment variable, `M2_HOME` environment variable.
   - `AetherUtils.findGlobalSettings()` now prefers the Maven `conf` directory over the Ant `etc` directory, and only returns an existing settings file.
   - Added a package-private `getMavenHome(Project, Map)` overload so the environment fallback can be tested deterministically.
   - New unit test `AetherUtilsTest` covering:
     - precedence of the `maven.home` Ant property over the system property,
     - fallback to the `maven.home` system property,
     - fallback to `MAVEN_HOME`, then `M2_HOME`,
     - Maven `conf` preferred over Ant `etc`,
     - fallback to Ant `etc` when no Maven settings file exists,
     - `null` when neither location holds a settings file.
   
   ## Verification
   
   - New tests fail on master (system property ignored; Ant `etc` wins) and pass with the fix.
   - `mvn verify` passes: all 63 tests succeed.
   


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Discover global settings from Maven home env vars and properties (#168) [maven-resolver-ant-tasks]

Posted by "elharo (via GitHub)" <gi...@apache.org>.
elharo commented on PR #177:
URL: https://github.com/apache/maven-resolver-ant-tasks/pull/177#issuecomment-5204435196

   Fixed the CI failures. `testFindGlobalSettingsFallsBackToAntEtc` and `testFindGlobalSettingsReturnsNullWhenNotFound` were not hermetic: on the CI runner the Maven wrapper sets `MAVEN_HOME`/`maven.home`, so the new fallback correctly resolved the real `conf/settings.xml`.
   
   - Added a package-private `findGlobalSettings(Project, Map<String, String>)` overload that takes the environment explicitly; the public `findGlobalSettings(Project)` delegates with `System.getenv()`.
   - The affected tests now call the overload with an empty environment map, so they no longer depend on the ambient environment.
   - Verified locally both with and without the `maven.home` system property set; `mvn verify` passes (63 tests).


-- 
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: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org