apache/maven · error · IllegalStateException

Could not parse current Maven version

Error message

Could not parse current Maven version: {}

What it means

After reading the version string, DefaultRuntimeInformation parses it with the injected version scheme. If the string does not form a valid Maven version (arbitrary text or a malformed value), the parse fails and the method throws IllegalStateException wrapping InvalidVersionSpecificationException, with the parse error included in the message.

Solutions

  1. Read the offending version from the exception message and restore a standard value such as 3.9.6 or 3.9.6-SNAPSHOT
  2. Rebuild or re-filter maven-version.properties from a clean build
  3. In tests, stub getMavenVersion() with a parseable version

Example fix

# before (maven-version.properties)
version=ver-$BUILD

# after
version=3.9.6
Defensive patterns

Strategy: try-catch

Validate before calling

String v = rtInfo.getMavenVersion();
if (!v.matches("[0-9]+(\\.[0-9]+)*(-[A-Za-z0-9.]+)?")) {
    throw new IllegalStateException("unparseable runtime version: " + v);
}

Try / catch

try {
    rtInfo.isMavenVersion(range);
} catch (IllegalStateException e) {
    // message includes the offending version string: fix the distribution metadata
    throw new IllegalStateException("bad maven-version.properties", e);
}

Prevention

When it happens

Trigger: maven-version.properties containing a hand-edited value the version scheme cannot parse, or test code stubbing the runtime version with a non-version string.

Common situations: Hand-built or patched Maven distributions; filtering pipelines that mangle the version placeholder; unit tests stubbing getMavenVersion with values like CURRENT or ver-one.

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/7a1d0d57fa0f9111. Report an issue: GitHub.

Appendix: source

Thrown at impl/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java:112

        }

        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)