{"record":{"id":"d23cf5213c82cf20","repo":"apache/maven","slug":"try-running-the-build-up-to-the-lifecycle-phase-p","errorCode":null,"errorMessage":"Try running the build up to the lifecycle phase \"package\"","messagePattern":"Try running the build up to the lifecycle phase \"package\"","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java","lineNumber":277,"sourceCode":"\n            result = dependenciesResolver.resolve(request);\n        } catch (DependencyResolutionException e) {\n            result = e.getResult();\n\n            /*\n             * MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator\n             * plugins that require dependency resolution, although they usually run in phases of the build where project\n             * artifacts haven't been assembled yet. The prime example of this is \"mvn release:prepare\".\n             */\n            if (aggregating && areAllDependenciesInReactor(session.getProjects(), result.getUnresolvedDependencies())) {\n                logger.warn(\"The following dependencies could not be resolved at this point of the build\"\n                        + \" but seem to be part of the reactor:\");\n\n                for (Dependency dependency : result.getUnresolvedDependencies()) {\n                    logger.warn(\"o {}\", dependency);\n                }\n\n                logger.warn(\"Try running the build up to the lifecycle phase \\\"package\\\"\");\n            } else {\n                throw new LifecycleExecutionException(messageBuilderFactory, null, project, e);\n            }\n        }\n\n        eventSpyDispatcher.onEvent(result);\n\n        Set<Artifact> artifacts = new LinkedHashSet<>();\n        if (result.getDependencyGraph() != null\n                && !result.getDependencyGraph().getChildren().isEmpty()) {\n            RepositoryUtils.toArtifacts(\n                    artifacts,\n                    result.getDependencyGraph().getChildren(),\n                    Collections.singletonList(project.getArtifact().getId()),\n                    collectionFilter);\n        }\n        return new SetWithResolutionResult(result, artifacts);\n    }","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java#L259-L295","documentation":"Emitted by LifecycleDependencyResolver when an aggregating mojo in a multi-module (reactor) build asks for the current project's dependencies before those artifacts have been assembled. Per MNG-2277, Maven tolerates the situation only when every unresolved dependency is itself a reactor project: it prints this warning plus the list of unresolved dependencies instead of failing; for non-aggregator mojos (or unresolved external deps) the same method throws LifecycleExecutionException. The warning tells you the plugin is running in a phase that precedes artifact assembly, which aggregator plugins like release:prepare historically do.","triggerScenarios":"Running an aggregator/plugin-without-project goal that triggers dependency resolution in a phase before 'package' in a multi-module build (prime example: 'mvn release:prepare'); a custom mojo marked @aggregator (or with requiresProject=false) that reads project.getArtifacts()/getDependencies() early; invoking a direct goal (e.g. 'mvn some-aggregator:goal') at the start of the reactor before upstream modules are built, where all missing GAVs match reactor projects (areAllDependenciesInReactor returns true).","commonSituations":"Multi-module release runs with maven-release-plugin; site or reporting aggregators bound to early phases; custom aggregator mojos resolving compile-scope dependencies of inter-dependent modules; partially built reactor where module A depends on module B but B's artifact is not yet packaged.","solutions":["Run the build up to 'package' first (e.g. 'mvn package') and then run the aggregator goal, exactly as the message suggests, so reactor artifacts exist in the local repo.","Bind the aggregator execution to 'package' or a later phase in the POM instead of an early phase (move <phase> in the plugin <execution>).","If the missing dependencies are NOT reactor projects, fix the actual resolution problem (missing version, wrong repository, not installed) — that path throws LifecycleExecutionException.","Plugin authors: defer dependency resolution until after packaging, or resolve only module-level dependencies that are already available instead of the full reactor artifact set."],"exampleFix":"// before: aggregator goal resolves deps before upstream modules are packaged\nmvn release:prepare   # warns: dependencies could not be resolved at this point\n\n// after: assemble reactor artifacts first, then run the aggregator goal\nmvn package\nmvn release:prepare","handlingStrategy":"validation","validationCode":"# guard: build reactor artifacts before any aggregator goal that resolves dependencies\nmvn -q -DskipTests package\nmvn release:prepare   # now reactor artifacts exist","typeGuard":null,"tryCatchPattern":"// embedders: the same method throws LifecycleExecutionException when deps are NOT in the reactor\ntry {\n    lifecycleModuleBuilder.buildProject(session, rootSession, currentSession, project, taskSegment);\n} catch (LifecycleExecutionException e) {\n    // inspect e.getMessage() for the unresolvable GAVs; fix POM/repos, do not retry blindly\n}","preventionTips":["Never bind aggregator executions to phases before 'package' in multi-module builds.","In CI, run 'mvn package' (or 'install') before standalone aggregator invocations like release:prepare.","Custom aggregator mojos: do not read project.getArtifacts() before packaging; resolve lazily or use reactor project references."],"tags":["maven","reactor","aggregator","dependency-resolution","lifecycle","multi-module"],"backgroundTag":"maven-could-not-resolve-dependencies","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}