quarkusio/quarkus · error · MojoExecutionException

The requested Maven version <requiredMavenVersionRange> is i

Error message

The requested Maven version <requiredMavenVersionRange> is invalid.

What it means

Thrown by QuarkusMavenPluginBase (ensureMavenVersion) when the version-range expression configured for the required Maven version cannot be parsed by Maven's VersionRange.createFromVersionSpec. The plugin checks the running Maven version against this range at build start; an unparseable range aborts the build before any goal logic runs. The original InvalidVersionSpecificationException is wrapped in a MojoExecutionException.

Source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/components/MavenVersionEnforcer.java:76

     * @param requiredMavenVersionRange range of allowed versions for Maven.
     * @param actualMavenVersion the version to be checked.
     * @throws MojoExecutionException the given version fails the enforcement rule
     */
    private void enforce(Log log,
            String requiredMavenVersionRange, ArtifactVersion actualMavenVersion)
            throws MojoExecutionException {
        if (StringUtils.isBlank(requiredMavenVersionRange)) {
            throw new MojoExecutionException("Maven version can't be empty.");
        }
        if (!actualMavenVersion.toString().equals(requiredMavenVersionRange)) {
            try {
                final VersionRange vr = VersionRange.createFromVersionSpec(requiredMavenVersionRange);
                if (!containsVersion(vr, actualMavenVersion)) {
                    throw new MojoExecutionException(getDetectedVersionStr(actualMavenVersion.toString())
                            + " is not supported, it must be in " + vr + ".");
                }
            } catch (InvalidVersionSpecificationException e) {
                throw new MojoExecutionException("The requested Maven version "
                        + requiredMavenVersionRange + " is invalid.", e);
            }
        }
        if (log.isDebugEnabled()) {
            log.debug(
                    getDetectedVersionStr(actualMavenVersion.toString()) + " is allowed in " + requiredMavenVersionRange + ".");
        }
    }

    /**
     * Copied from Artifact.VersionRange. This is tweaked to handle singular ranges properly. Currently, the default
     * <code>containsVersion</code> method assumes a singular version means allow everything.
     *
     * @param allowedRange range of allowed versions.
     * @param theVersion the version to be checked.
     * @return {@code true} if the version is contained by the range.
     */
    private static boolean containsVersion(VersionRange allowedRange, ArtifactVersion theVersion) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix the requiredMavenVersionRange value to valid Maven version-range syntax, e.g. [3.8.2,) — check the pom.xml where the Quarkus Maven plugin is configured.
  2. If the range comes from a property, verify the property is defined and resolves correctly (mvn help:effective-pom).
  3. If the range is hardcoded in a custom mojo, correct the literal passed to ensureMavenVersion.
  4. Temporarily print the resolved value with mvn help:evaluate -Dexpression=<property> to see exactly what string is being parsed.

Example fix

// before (pom.xml)
<requiredMavenVersionRange>[3.8.2</requiredMavenVersionRange>
// after
<requiredMavenVersionRange>[3.8.2,)</requiredMavenVersionRange>
Defensive patterns

Strategy: validation

Validate before calling

import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;

boolean isValidRange(String spec) {
    try {
        VersionRange.createFromVersionSpec(spec);
        return true;
    } catch (InvalidVersionSpecificationException e) {
        return false;
    }
}
// before the build: assert isValidRange("[3.8.2,)")

Prevention

When it happens

Trigger: The requiredMavenVersionRange parameter passed to ensureMavenVersion contains syntax VersionRange cannot parse — e.g. a typo like '3.8.' or '[3.8,)' miswritten as '3,8' or an unclosed bracket '[3.8,2.0'.

Common situations: Hand-editing requiredMavenVersionRange in pom.xml or a parent POM; copy-pasting a range with smart quotes or whitespace typos; a custom Quarkus mojo/plugin configuration supplying a malformed property value; IDE property placeholders left unresolved like ${req.maven.range} resolving to garbage.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/cb26d69db0c46c54. Report an issue: GitHub.