apache/maven · error · MavenExecutionException
Could not find the selected project in the reactor: {}
Error message
Could not find the selected project in the reactor: {} What it means
Deprecated (since 4.0.0) variant of project-selection failure: getRequiredProjectsBySelectors() throws immediately when a selector resolves to no reactor project. Unlike the newer getActiveProjects, there is no optional/required distinction and no batching of unmatched selectors. Matching rules are identical: ':artifactId', 'groupId:artifactId', or a path relative to the base directory (file or directory match).
Source
Thrown at impl/maven-core/src/main/java/org/apache/maven/graph/ProjectSelector.java:101
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)
throws MavenExecutionException {
Set<MavenProject> selectedProjects = new LinkedHashSet<>();
File baseDirectory = getBaseDirectoryFromRequest(request);
for (String selector : projectSelectors) {
Optional<MavenProject> optSelectedProject =
findOptionalProjectBySelector(projects, baseDirectory, selector);
if (!optSelectedProject.isPresent()) {
String message = "Could not find the selected project in the reactor: " + selector;
throw new MavenExecutionException(message, request.getPom());
}
MavenProject selectedProject = optSelectedProject.get();
selectedProjects.add(selectedProject);
selectedProjects.addAll(getChildProjects(selectedProject, request));
}
return selectedProjects;
}
/**
* @deprecated use {@link #getActiveProjects(MavenExecutionRequest, List, List)}
*/
@Deprecated(since = "4.0.0")
public Set<MavenProject> getOptionalProjectsBySelectors(
MavenExecutionRequest request, List<MavenProject> projects, Set<String> projectSelectors) {
Set<MavenProject> resolvedOptionalProjects = new LinkedHashSet<>();View on GitHub (pinned to e4093d4e12)
Solutions
- Fix the selector to match a reactor module (':artifactId' form is most robust)
- Run from the reactor root so path selectors resolve
- Migrate calling code to getActiveProjects(request, projects, activations), which distinguishes optional selectors
- Enable profiles required for the target module to be in the reactor
Example fix
// before: legacy call with a bad selector
selector.getRequiredProjectsBySelectors(request, projects, Set.of(":nope"));
// after: modern API with explicit activations
selector.getActiveProjects(request, projects, activationList); Defensive patterns
Strategy: validation
Validate before calling
// Pre-check each selector the way the deprecated method matches
Optional<MavenProject> hit = projects.stream()
.filter(p -> (":" + p.getArtifactId()).equals(selector)
|| (p.getGroupId() + ":" + p.getArtifactId()).equals(selector)
|| pathMatches(p, selector, baseDirectory))
.findFirst();
if (hit.isEmpty()) throw new IllegalArgumentException("No reactor project for selector: " + selector); Try / catch
try {
selected = selector.getRequiredProjectsBySelectors(request, projects, selectors);
} catch (MavenExecutionException e) {
if (e.getMessage().startsWith("Could not find the selected project")) {
// selector typo: extract and report, then continue with remaining selectors
log.warn("Skipping unmatched selector: {}", e.getMessage());
selected = Collections.emptySet();
} else throw e;
} Prevention
- Migrate to getActiveProjects for optional-selector semantics
- Validate selectors against the module list before invoking legacy APIs
When it happens
Trigger: Calling ProjectSelector.getRequiredProjectsBySelectors(...) directly (or via legacy graph-builder paths) with a selector matching no project's artifactId/groupId combination or basedir/pom file under the request's base directory.
Common situations: Custom tooling or old Maven forks still routing through the deprecated selector; same root causes as the modern variant: typos, wrong working directory, or modules excluded from the reactor.
Related errors
- The project exclusion%s in --projects/-pl resulted in an emp
- The requested required projects {} do not exist.
- Two or more projects in the reactor have the same identifier
- Invalid reactor make behavior: {}
- Edge between '{}' and '{}' introduces to cycle in the graph
AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21).
Data as JSON: /api/errors/9fa84e004b80b33c.
Report an issue: GitHub.