apache/maven · error · IllegalArgumentException
Could not determine current Maven version
Error message
Could not determine current Maven version
What it means
isMavenVersion needs the running Maven's version, which DefaultRuntimeInformation reads from the filtered maven-version.properties resource. If the version entry is missing or still contains the unfiltered ${...} placeholder, getMavenVersion() returns the empty string and the method throws IllegalArgumentException 'Could not determine current Maven version'.
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java:107
@Override
public boolean isMavenVersion(String versionRange) {
if (Objects.requireNonNull(versionRange, "versionRange cannot be null").isEmpty()) {
throw new IllegalArgumentException("versionRange cannot be empty");
}
VersionConstraint constraint;
try {
constraint = versionScheme.parseVersionConstraint(versionRange);
} catch (InvalidVersionSpecificationException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
Version current;
try {
String mavenVersion = getMavenVersion();
if (mavenVersion.isEmpty()) {
throw new IllegalArgumentException("Could not determine current Maven version");
}
current = versionScheme.parseVersion(mavenVersion);
} catch (InvalidVersionSpecificationException e) {
throw new IllegalStateException("Could not parse current Maven version: " + e.getMessage(), e);
}
if (constraint.getRange() == null) {
return constraint.getVersion().compareTo(current) <= 0;
}
return constraint.containsVersion(current);
}
}
View on GitHub (pinned to e4093d4e12)
Solutions
- Verify the jar you run against contains META-INF/maven/org.apache.maven/maven-version.properties with a resolved version entry
- If embedding, generate that file yourself with a real version, e.g. version=3.9.6
- Prefer running inside an official Maven distribution (sanity-check with mvn -version)
Example fix
# before: META-INF/maven/org.apache.maven/maven-version.properties missing or unfiltered
version=${project.version}
# after
version=3.9.6 Defensive patterns
Strategy: validation
Validate before calling
if (rtInfo.getMavenVersion() == null || rtInfo.getMavenVersion().isEmpty()) {
throw new IllegalStateException("this distribution lacks maven-version.properties; refusing version checks");
}
rtInfo.isMavenVersion(range); Try / catch
try {
rtInfo.isMavenVersion(range);
} catch (IllegalArgumentException e) {
// 'Could not determine current Maven version': the runtime metadata is missing
log.error("not running inside a proper Maven distribution", e);
} Prevention
- Smoke-test custom Maven distributions with mvn -version before running builds
- When embedding maven-core, ship the filtered maven-version.properties alongside it
When it happens
Trigger: Executing maven-core outside a properly assembled distribution: a jar built without resource filtering, a custom or shaded Maven assembly that lost META-INF/maven/org.apache.maven/maven-version.properties, or a corrupted install.
Common situations: Embedding maven-core in an application or test harness; 'thin' custom distributions; running against maven-core classes straight from a repository without the generated properties file.
Related errors
- Cannot read metadata from '{}': {}
- {} could not be retrieved from repository: {} due to an erro
- Error installing metadata: {}
- Error while deploying metadata: {}
- Cannot add two different pieces of metadata for: " + getKey(
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/cb05c607453dcd27.
Report an issue: GitHub.