{"record":{"id":"9fa84e004b80b33c","repo":"apache/maven","slug":"could-not-find-the-selected-project-in-the-reactor","errorCode":null,"errorMessage":"Could not find the selected project in the reactor: {}","messagePattern":"Could not find the selected project in the reactor: (.+?)","errorType":"exception","errorClass":"MavenExecutionException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/graph/ProjectSelector.java","lineNumber":101,"sourceCode":"\n        return resolvedOptionalProjects;\n    }\n\n    /**\n     * @deprecated use {@link #getActiveProjects(MavenExecutionRequest, List, List)}\n     */\n    @Deprecated(since = \"4.0.0\")\n    public Set<MavenProject> getRequiredProjectsBySelectors(\n            MavenExecutionRequest request, List<MavenProject> projects, Set<String> projectSelectors)\n            throws MavenExecutionException {\n        Set<MavenProject> selectedProjects = new LinkedHashSet<>();\n        File baseDirectory = getBaseDirectoryFromRequest(request);\n        for (String selector : projectSelectors) {\n            Optional<MavenProject> optSelectedProject =\n                    findOptionalProjectBySelector(projects, baseDirectory, selector);\n            if (!optSelectedProject.isPresent()) {\n                String message = \"Could not find the selected project in the reactor: \" + selector;\n                throw new MavenExecutionException(message, request.getPom());\n            }\n\n            MavenProject selectedProject = optSelectedProject.get();\n\n            selectedProjects.add(selectedProject);\n            selectedProjects.addAll(getChildProjects(selectedProject, request));\n        }\n\n        return selectedProjects;\n    }\n\n    /**\n     * @deprecated use {@link #getActiveProjects(MavenExecutionRequest, List, List)}\n     */\n    @Deprecated(since = \"4.0.0\")\n    public Set<MavenProject> getOptionalProjectsBySelectors(\n            MavenExecutionRequest request, List<MavenProject> projects, Set<String> projectSelectors) {\n        Set<MavenProject> resolvedOptionalProjects = new LinkedHashSet<>();","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/graph/ProjectSelector.java#L83-L119","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: legacy call with a bad selector\nselector.getRequiredProjectsBySelectors(request, projects, Set.of(\":nope\"));\n\n// after: modern API with explicit activations\nselector.getActiveProjects(request, projects, activationList);","handlingStrategy":"validation","validationCode":"// Pre-check each selector the way the deprecated method matches\nOptional<MavenProject> hit = projects.stream()\n    .filter(p -> (\":\" + p.getArtifactId()).equals(selector)\n              || (p.getGroupId() + \":\" + p.getArtifactId()).equals(selector)\n              || pathMatches(p, selector, baseDirectory))\n    .findFirst();\nif (hit.isEmpty()) throw new IllegalArgumentException(\"No reactor project for selector: \" + selector);","typeGuard":null,"tryCatchPattern":"try {\n    selected = selector.getRequiredProjectsBySelectors(request, projects, selectors);\n} catch (MavenExecutionException e) {\n    if (e.getMessage().startsWith(\"Could not find the selected project\")) {\n        // selector typo: extract and report, then continue with remaining selectors\n        log.warn(\"Skipping unmatched selector: {}\", e.getMessage());\n        selected = Collections.emptySet();\n    } else throw e;\n}","preventionTips":["Migrate to getActiveProjects for optional-selector semantics","Validate selectors against the module list before invoking legacy APIs"],"tags":["maven","projects-option","deprecated-api","project-selection","reactor"],"backgroundTag":"unknown-module-selection","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}