{"record":{"id":"46838c1895c093c4","repo":"quarkusio/quarkus","slug":"failed-to-find-project-for-dependency","errorCode":null,"errorMessage":"Failed to find project for dependency: ","messagePattern":"Failed to find project for dependency: ","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyDataCollector.java","lineNumber":318,"sourceCode":"    }\n\n    private static void addDeclaredFromConfig(Project p, String cfgName, String scope,\n            Map<GAV, DeclaredDependency> out) {\n        final Configuration cfg = p.getConfigurations().findByName(cfgName);\n        if (cfg == null) {\n            return;\n        }\n\n        for (var d : cfg.getDependencies()) {\n            var gav = new GAV(\n                    String.valueOf(d.getGroup()),\n                    d.getName(),\n                    String.valueOf(d.getVersion()));\n            if (d instanceof ProjectDependency pd) {\n                Project dp = p.findProject(pd.getPath());\n                if (dp == null) {\n                    // should not happen\n                    throw new GradleException(\"Failed to find project for dependency: \" + pd.getPath());\n                }\n            }\n            out.put(gav, new DeclaredDependency(\n                    gav.getGroupId(),\n                    gav.getArtifactId(),\n                    gav.getVersion(),\n                    null,\n                    null,\n                    scope,\n                    false));\n\n        }\n    }\n\n    private static List<DeclaredDependency> toDeclaredDependencies(Model model) {\n        final List<DeclaredDependency> declaredDeps = new ArrayList<>();\n        for (org.apache.maven.model.Dependency dep : model.getDependencies()) {\n            if (!SCOPE_TEST.equals(dep.getScope())) {","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/gradle/gradle-model/src/main/java/io/quarkus/gradle/tooling/dependency/DependencyDataCollector.java#L300-L336","documentation":"In DependencyDataCollector.addDeclaredFromConfig, when a declared dependency is a ProjectDependency, the code verifies the target project actually exists via Project.findProject(path). The comment says 'should not happen' — a ProjectDependency should always reference a project in the same build — so failing the lookup indicates a corrupted or inconsistent project model, and a GradleException is thrown with the dependency path in the message.","triggerScenarios":"Calling collectDeclaredFromProject over configuration dependencies when a ProjectDependency's path (pd.getPath()) is not found by p.findProject(pd.getPath()) — e.g. cross-build project dependencies or projects registered under a different path than the dependency claims.","commonSituations":"Composite builds substituting a module with a project from another build whose path is not resolvable from the current root; renamed subprojects after stale Gradle daemon state; generated projects where settings.gradle and dependency declarations disagree.","solutions":["Stop the Gradle daemon and rebuild (./gradlew --stop) to discard a stale project model","Verify the project path in the error exists in settings.gradle include statements","Check for composite-build project substitutions that point across build boundaries; declare the dependency via includeBuild + substitution instead","Clear the configuration cache (.gradle/configuration-cache) if enabled","If reproducible, file a Quarkus issue with the project layout — this is expected to be unreachable"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"d.getDependencyConstraint();\nif (d instanceof ProjectDependency pd && p.findProject(pd.getPath()) == null) {\n    throw new IllegalStateException(\"ProjectDependency path not resolvable: \" + pd.getPath());\n}","typeGuard":null,"tryCatchPattern":"try {\n    collector.collectDeclaredFromProject(project);\n} catch (GradleException e) {\n    if (e.getMessage().startsWith(\"Failed to find project for dependency:\")) {\n        logger.warn(\"Stale project model; retry after ./gradlew --stop\");\n    } else throw e;\n}","preventionTips":["Keep settings.gradle includes in sync with ProjectDependency declarations","Stop the daemon after structural project changes","Prefer includeBuild + dependency substitution over cross-build project paths","Clear .gradle/configuration-cache when project layout changes"],"tags":["gradle","dependencies","project-dependency"],"backgroundTag":"gradle-project-lookup-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}