{"record":{"id":"2f1d522683ffcdfe","repo":"apache/maven","slug":"illegal-call-to-phase-the-main-phase-wi-2f1d52","errorCode":null,"errorMessage":"Illegal call to phase '{}'. The main phase '{}' will be used instead.","messagePattern":"Illegal call to phase '(.+?)'\\. The main phase '(.+?)' will be used instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/ConcurrentLifecycleStarter.java","lineNumber":147,"sourceCode":"                        && !rootProject.getDefaultGoal().isEmpty())) {\n            tasks = Stream.of(rootProject.getDefaultGoal().split(\"\\\\s+\"))\n                    .filter(g -> !g.isEmpty())\n                    .collect(Collectors.toList());\n        }\n\n        return calculateTaskSegments(session, tasks);\n    }\n\n    public List<TaskSegment> calculateTaskSegments(MavenSession session, List<String> tasks) throws Exception {\n        List<TaskSegment> taskSegments = new ArrayList<>(tasks.size());\n\n        TaskSegment currentSegment = null;\n\n        for (String task : tasks) {\n            if (isBeforeOrAfterPhase(task)) {\n                String prevTask = task;\n                task = PhaseId.of(task).phase();\n                logger.warn(\"Illegal call to phase '{}'. The main phase '{}' will be used instead.\", prevTask, task);\n            }\n            if (isGoalSpecification(task)) {\n                // \"pluginPrefix[:version]:goal\" or \"groupId:artifactId[:version]:goal\"\n\n                lifecyclePluginResolver.resolveMissingPluginVersions(session.getTopLevelProject(), session);\n\n                MojoDescriptor mojoDescriptor =\n                        mojoDescriptorCreator.getMojoDescriptor(task, session, session.getTopLevelProject());\n\n                boolean aggregating = mojoDescriptor.isAggregator() || !mojoDescriptor.isProjectRequired();\n\n                if (currentSegment == null || currentSegment.isAggregating() != aggregating) {\n                    currentSegment = new TaskSegment(aggregating);\n                    taskSegments.add(currentSegment);\n                }\n\n                currentSegment.getTasks().add(new GoalTask(task));\n            } else {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/concurrent/ConcurrentLifecycleStarter.java#L129-L165","documentation":"ConcurrentLifecycleStarter.calculateTaskSegments() validates each requested task; isBeforeOrAfterPhase() checks task.startsWith(Lifecycle.BEFORE) or AFTER — the pre-/post- companion phases like pre-clean, post-clean, post-deploy that only exist as hooks inside a full lifecycle. Directly invoking one is illegal, so Maven maps it via PhaseId.of(task).phase() to the main phase and warns that the main phase will be executed instead.","triggerScenarios":"Passing a hook phase as a task on the command line or via goals: 'mvn post-clean', 'mvn pre-site', 'mvn post-deploy' — anything starting with 'pre-' or 'post-' that resolves to a lifecycle phase id.","commonSituations":"Scripts trying to run 'only the cleanup hook' or CI jobs copying phase names from docs; users assuming pre-*/post-* are independently runnable phases; migration from tools where such phases are first-class.","solutions":["Invoke the main phase instead: 'mvn clean' instead of 'mvn post-clean', 'mvn deploy' instead of 'mvn post-deploy'.","To run only a hook's bound plugin executions, invoke the plugin goals directly (e.g. 'mvn clean:clean') or bind them to a custom phase.","Audit build scripts/CI yaml for task names starting with pre-/post- that are lifecycle phases."],"exampleFix":"# before\nmvn post-clean   # warns: Illegal call to phase 'post-clean'. 'clean' used\n\n# after\nmvn clean","handlingStrategy":"validation","validationCode":"# guard: reject hook phases (pre-*/post-*) as tasks before invoking Maven\nfor task in \"$@\"; do\n  case \"$task\" in\n    pre-*|post-*) echo \"illegal direct phase: $task (use the main lifecycle phase)\"; exit 2;;\n  esac\ndone\nmvn \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat pre-clean/post-clean/pre-site/post-site/post-deploy as hooks, never as standalone goals.","To execute only hook-bound executions, invoke the specific plugin goals instead of the hook phase."],"tags":["maven","lifecycle","phase-invocation","concurrent-build","cli"],"backgroundTag":"invalid-lifecycle-phase-invocation","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}