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/03 18:20:36 UTC
[I] Global settings.xml discovery ignores MAVEN_HOME/M2_HOME env vars and maven.home system property [maven-resolver-ant-tasks]
elharo opened a new issue, #168:
URL: https://github.com/apache/maven-resolver-ant-tasks/issues/168
## Summary
Global `settings.xml` discovery reads only the `maven.home` Ant property and never falls back to the `MAVEN_HOME`/`M2_HOME` environment variables (or `System.getProperty("maven.home")`), so global mirrors/proxies/servers are silently not loaded in typical Ant builds.
## Affected code
`src/main/java/org/apache/maven/resolver/internal/ant/AetherUtils.java` (master @ `df2908e`)
```java
public static File findGlobalSettings(final Project project) {
final File file = new File(new File(project.getProperty("ant.home"), "etc"), Names.SETTINGS_XML);
if (file.isFile()) {
return file;
} else {
final String mavenHome = getMavenHome(project);
if (mavenHome != null) {
return new File(new File(mavenHome, "conf"), Names.SETTINGS_XML);
}
}
return null;
}
public static String getMavenHome(final Project project) {
return project.getProperty("maven.home");
}
```
## Problem
`getMavenHome()` only consults the `maven.home` Ant property, which is almost never set by a plain Ant invocation. Maven itself resolves the installation directory from the `MAVEN_HOME`/`M2_HOME` environment variables or the `maven.home` system property. In addition, `findGlobalSettings()` checks `$ANT_HOME/etc/settings.xml` first, giving ANT_HOME precedence over MAVEN_HOME — likely inverted.
## Expected behavior
Resolve the Maven home from (in order): `maven.home` Ant property, `System.getProperty("maven.home")`, `MAVEN_HOME` env var, `M2_HOME` env var. Prefer the Maven conf directory over the Ant etc directory.
## Impact
Global settings.xml (mirrors, proxies, server credentials) are silently ignored in most Ant builds.
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org