apache/maven · error · IllegalArgumentException

versionRange cannot be empty

Error message

versionRange cannot be empty

What it means

RuntimeInformation.isMavenVersion(String versionRange) compares the running Maven version against a Maven version constraint such as "[3.0,)" or a plain version. The argument is mandatory: null is rejected by Objects.requireNonNull and the empty string by this IllegalArgumentException, because an empty constraint is meaningless and almost always indicates an unset property.

Source

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

                logger.warn(msg, e);
            } else {
                logger.warn(msg);
            }
        }

        String version = props.getProperty("version", "").trim();

        if (!version.startsWith("${")) {
            return version;
        } else {
            return "";
        }
    }

    @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) {

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Give the source property a concrete default, e.g. <properties><maven.min.version>[3.6.3,)</maven.min.version></properties>
  2. Guard the call: skip the check or substitute a sane default when the configured value is blank
  3. Pass a literal constraint such as "[3.0,)"

Example fix

// before
boolean ok = rtInfo.isMavenVersion(range); // range == "" when the property is unset

// after
String range = Optional.ofNullable(props.getProperty("maven.min.version"))
        .filter(s -> !s.isBlank())
        .orElse("[3.6.3,)");
boolean ok = rtInfo.isMavenVersion(range);
Defensive patterns

Strategy: validation

Validate before calling

if (range == null || range.isBlank()) {
    range = "[3.6.3,)"; // or reject with a clear configuration error
}
boolean ok = rtInfo.isMavenVersion(range);

Try / catch

try {
    rtInfo.isMavenVersion(configuredRange);
} catch (IllegalArgumentException e) {
    throw new MojoExecutionException("version range misconfigured: '" + configuredRange + "'", e);
}

Prevention

When it happens

Trigger: rtInfo.isMavenVersion("") — most often a configurable value like ${maven.min.version} that resolved to empty because the property was never defined, or code that defaults missing config to the empty string.

Common situations: Prerequisite checks in mojos or extensions reading a version range from plugin configuration or a property that is absent; copy-pasted code where the range constant was deleted.

Related errors


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