apache/maven · error · MavenExecutionException

The requested required projects {} do not exist.

Error message

The requested required projects {} do not exist.

What it means

MavenExecutionException listing all REQUIRED project selectors that matched no project in the reactor. ProjectSelector.getActiveProjects() resolves each -pl selector (':artifactId', 'groupId:artifactId', or a path relative to the request base directory) and collects unmatched ones; selectors marked optional (-pl '?name') only log an info message, but required unmatched selectors fail the build with this joined list.

Source

Thrown at impl/maven-core/src/main/java/org/apache/maven/graph/ProjectSelector.java:74

                Optional<MavenProject> optSelectedProject =
                        findOptionalProjectBySelector(projects, baseDirectory, selector);
                if (optSelectedProject.isPresent()) {
                    resolvedOptionalProjects.add(optSelectedProject.get());
                    if (activation.activationSettings().recurse()) {
                        resolvedOptionalProjects.addAll(getChildProjects(optSelectedProject.get(), request));
                    }
                } else {
                    unresolvedSelectors.add(activation);
                }
            }
        }
        if (!unresolvedSelectors.isEmpty()) {
            String requiredSelectors = unresolvedSelectors.stream()
                    .filter(pas -> !pas.activationSettings().optional())
                    .map(ProjectActivation.ProjectActivationSettings::selector)
                    .collect(Collectors.joining(", "));
            if (!requiredSelectors.isEmpty()) {
                throw new MavenExecutionException(
                        "The requested required projects " + requiredSelectors + " do not exist.", request.getPom());
            } else {
                String optionalSelectors = unresolvedSelectors.stream()
                        .map(ProjectActivation.ProjectActivationSettings::selector)
                        .collect(Collectors.joining(", "));
                LOGGER.info("The requested optional projects {} do not exist.", optionalSelectors);
            }
        }

        return resolvedOptionalProjects;
    }

    /**
     * @deprecated use {@link #getActiveProjects(MavenExecutionRequest, List, List)}
     */
    @Deprecated(since = "4.0.0")
    public Set<MavenProject> getRequiredProjectsBySelectors(
            MavenExecutionRequest request, List<MavenProject> projects, Set<String> projectSelectors)

View on GitHub (pinned to e4093d4e12)

Solutions

  1. List the reactor modules (build summary or the pom <modules>) and fix the selector spelling
  2. Run from the reactor root so relative-path selectors resolve, or switch to the ':artifactId' form
  3. If the module's presence is conditional, mark the selector optional: -pl '?module' so its absence only logs
  4. Ensure any profile needed to include the module in the reactor is enabled

Example fix

# before: module renamed, selector no longer matches
mvn -pl :old-name install

# after: selector matches a reactor module
mvn -pl :new-name install
Defensive patterns

Strategy: validation

Validate before calling

// Resolve each selector against the known reactor before running Maven
boolean matches = projects.stream().anyMatch(p ->
    (":" + p.getArtifactId()).equals(selector)
    || (p.getGroupId() + ":" + p.getArtifactId()).equals(selector)
    || pathMatches(p, selector, baseDir));
if (!matches && !selector.startsWith("?")) {
    throw new IllegalArgumentException("Selector matches no reactor project: " + selector);
}

Prevention

When it happens

Trigger: mvn -pl :artifactId or -pl relative/path where no reactor project has that artifactId, groupId:artifactId, or a basedir/pom file matching the selector path resolved against the base directory; the path branch also matches a selector that points at a pom file.

Common situations: Typos in module names or artifactIds; modules deactivated by their activation profiles; running from a subdirectory so relative path selectors no longer resolve; modules renamed during refactoring while CI commands were not updated.

Related errors


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