apache / apache/maven-resolver-ant-tasks

Global settings.xml discovery ignores MAVEN_HOME/M2_HOME env vars and maven.home system property

Open
#168 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
15
Forks
18
Avg merge
1d 5h
Merged PRs (30d)
8

Description

## 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/main/java/org/apache/maven/resolver/internal/ant/AetherUtils.java by reading getMavenHome(Project) and findGlobalSettings(Project). Verify the existing Ant property, system property, and environment-variable resolution, then confirm that Maven's conf/settings.xml takes precedence over Ant's etc/settings.xml. Done means global settings are found using the stated precedence in plain Ant builds.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.