{"record":{"id":"cb05c607453dcd27","repo":"apache/maven","slug":"could-not-determine-current-maven-version","errorCode":null,"errorMessage":"Could not determine current Maven version","messagePattern":"Could not determine current Maven version","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java","lineNumber":107,"sourceCode":"\n    @Override\n    public boolean isMavenVersion(String versionRange) {\n        if (Objects.requireNonNull(versionRange, \"versionRange cannot be null\").isEmpty()) {\n            throw new IllegalArgumentException(\"versionRange cannot be empty\");\n        }\n\n        VersionConstraint constraint;\n        try {\n            constraint = versionScheme.parseVersionConstraint(versionRange);\n        } catch (InvalidVersionSpecificationException e) {\n            throw new IllegalArgumentException(e.getMessage(), e);\n        }\n\n        Version current;\n        try {\n            String mavenVersion = getMavenVersion();\n            if (mavenVersion.isEmpty()) {\n                throw new IllegalArgumentException(\"Could not determine current Maven version\");\n            }\n\n            current = versionScheme.parseVersion(mavenVersion);\n        } catch (InvalidVersionSpecificationException e) {\n            throw new IllegalStateException(\"Could not parse current Maven version: \" + e.getMessage(), e);\n        }\n\n        if (constraint.getRange() == null) {\n            return constraint.getVersion().compareTo(current) <= 0;\n        }\n        return constraint.containsVersion(current);\n    }\n}\n","sourceCodeStart":89,"sourceCodeEnd":121,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/rtinfo/internal/DefaultRuntimeInformation.java#L89-L121","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"# before: META-INF/maven/org.apache.maven/maven-version.properties missing or unfiltered\nversion=${project.version}\n\n# after\nversion=3.9.6","handlingStrategy":"validation","validationCode":"if (rtInfo.getMavenVersion() == null || rtInfo.getMavenVersion().isEmpty()) {\n    throw new IllegalStateException(\"this distribution lacks maven-version.properties; refusing version checks\");\n}\nrtInfo.isMavenVersion(range);","typeGuard":null,"tryCatchPattern":"try {\n    rtInfo.isMavenVersion(range);\n} catch (IllegalArgumentException e) {\n    // 'Could not determine current Maven version': the runtime metadata is missing\n    log.error(\"not running inside a proper Maven distribution\", e);\n}","preventionTips":["Smoke-test custom Maven distributions with mvn -version before running builds","When embedding maven-core, ship the filtered maven-version.properties alongside it"],"tags":["maven","runtime-info","metadata","embedder","classloader"],"backgroundTag":"missing-version-metadata","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}