{"record":{"id":"b7c19bdc857be566","repo":"apache/maven","slug":"no-goals-have-been-specified-for-this-build-you-m","errorCode":null,"errorMessage":"No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: {}.","messagePattern":"No goals have been specified for this build\\. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>\\[:<plugin-version>\\]:<goal>\\. Available lifecycle phases are: (.+?)\\.","errorType":"exception","errorClass":"NoGoalSpecifiedException","httpStatus":null,"severity":"error","filePath":"impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleStarter.java","lineNumber":95,"sourceCode":"    public void execute(MavenSession session) {\n        eventCatapult.fire(ExecutionEvent.Type.SessionStarted, session, null);\n\n        ReactorContext reactorContext = null;\n        ProjectBuildList projectBuilds = null;\n        MavenExecutionResult result = session.getResult();\n\n        try {\n            if (buildExecutionRequiresProject(session) && projectIsNotPresent(session)) {\n                throw new MissingProjectException(\"The goal you specified requires a project to execute\"\n                        + \" but there is no POM in this directory (\" + session.getExecutionRootDirectory() + \").\"\n                        + \" Please verify you invoked Maven from the correct directory.\");\n            }\n\n            List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments(session);\n            projectBuilds = buildListCalculator.calculateProjectBuilds(session, taskSegments);\n\n            if (projectBuilds.isEmpty()) {\n                throw new NoGoalSpecifiedException(\"No goals have been specified for this build.\"\n                        + \" You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or\"\n                        + \" <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>.\"\n                        + \" Available lifecycle phases are: \" + defaultLifeCycles.getLifecyclePhaseList() + \".\");\n            }\n\n            if (logger.isDebugEnabled()) {\n                lifecycleDebugLogger.debugReactorPlan(projectBuilds);\n            }\n\n            ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();\n            ReactorBuildStatus reactorBuildStatus = new ReactorBuildStatus(session.getProjectDependencyGraph());\n            reactorContext = new ReactorContext(result, oldContextClassLoader, reactorBuildStatus);\n\n            String builderId = session.getRequest().getBuilderId();\n            Builder builder = builders.get(builderId);\n            if (builder == null) {\n                throw new BuilderNotFoundException(\n                        String.format(\"The builder requested using id = %s cannot be\" + \" found\", builderId));","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleStarter.java#L77-L113","documentation":"After calculating task segments and project builds, if the resulting ProjectBuildList is empty, DefaultLifecycleStarter throws NoGoalSpecifiedException: Maven was invoked with nothing to do — no lifecycle phase and no plugin goal survived into the task segments (which also covers bare 'mvn' with no arguments).","triggerScenarios":"Running 'mvn' with no goals; passing only flags (-T 1C, -DskipTests, --file pom.xml) without a phase/goal; all requested tasks filtered out by task-segment calculation; -Dgoals style configurations where the property supplying goals is empty.","commonSituations":"CI scripts building the goal list from an empty variable: mvn ${GOALS} with GOALS unset; shell quoting bugs that drop the goal argument; users expecting a default phase like 'install' to run implicitly.","solutions":["Add an explicit lifecycle phase or goal: mvn install / mvn org.acme:plugin:1.0:goal","If goals come from a variable, guard the script: ${GOALS:?no goals set} or set a default GOALS=${GOALS:-package}","Review the message's list of valid phases when unsure of naming"],"exampleFix":"# before\nmvn ${GOALS}   # GOALS unset -> NoGoalSpecifiedException\n\n# after\nGOALS=${GOALS:-package}\nmvn ${GOALS}","handlingStrategy":"validation","validationCode":"// never invoke Maven with an empty goal list\nif (goals == null || goals.isBlank()) throw new IllegalArgumentException(\"No goals specified\");","typeGuard":null,"tryCatchPattern":"catch (NoGoalSpecifiedException e) {\n    // default the build to a sane phase (e.g. 'package') and retry\n}","preventionTips":["Default goal variables: mvn ${GOALS:-install}","Set <default-goal> in POMs where a bare 'mvn' should do something","Fail fast in wrappers when the computed goal list is empty"],"tags":["maven","cli","no-goal","task-segments"],"backgroundTag":"no-goal-specified","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}