{"record":{"id":"4e9ffa01f2d81de5","repo":"quarkusio/quarkus","slug":"there-is-no-rootproject-defined-in-this-gradlebuil","errorCode":null,"errorMessage":"There is no rootProject defined in this GradleBuildFile","messagePattern":"There is no rootProject defined in this GradleBuildFile","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFile.java","lineNumber":161,"sourceCode":"        });\n    }\n\n    @Override\n    protected void refreshData() {\n        this.modelReference.set(null);\n    }\n\n    private boolean hasRootProjectFile(final String fileName) {\n        if (rootProjectPath == null) {\n            return false;\n        }\n        final Path filePath = rootProjectPath.resolve(fileName);\n        return Files.exists(filePath);\n    }\n\n    private byte[] readRootProjectFile(final String fileName) throws IOException {\n        if (rootProjectPath == null) {\n            throw new IllegalStateException(\"There is no rootProject defined in this GradleBuildFile\");\n        }\n        final Path filePath = rootProjectPath.resolve(fileName);\n        return Files.readAllBytes(filePath);\n    }\n\n    private Model readModel() throws IOException {\n        String settingsContent = \"\";\n        String buildContent = \"\";\n        Properties propertiesContent = new Properties();\n        String rootSettingsContent = null;\n        Properties rootPropertiesContent = null;\n        if (hasProjectFile(getSettingsGradlePath())) {\n            final byte[] settings = readProjectFile(getSettingsGradlePath());\n            settingsContent = new String(settings, StandardCharsets.UTF_8);\n        }\n        if (hasRootProjectFile(getSettingsGradlePath())) {\n            final byte[] settings = readRootProjectFile(getSettingsGradlePath());\n            rootSettingsContent = new String(settings, StandardCharsets.UTF_8);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/buildfile/AbstractGradleBuildFile.java#L143-L179","documentation":"AbstractGradleBuildFile.readRootProjectFile(fileName) reads files (like gradle.properties or settings via settings()/properties()) relative to the root project directory. If rootProjectPath was never set (multi-module layouts where no root project was identified), it throws IllegalStateException with this message instead of failing with an IO error.","triggerScenarios":"Calling settings() or properties() on an AbstractGradleBuildFile instance whose rootProjectPath is null — i.e. the build file was created without a resolvable root project directory (no settings.gradle found above the build file).","commonSituations":"Using the devtools Gradle project API in a nested/submodule directory where no settings.gradle exists in any parent; programmatically constructing GradleBuildFile without establishing the root project; renaming/moving settings.gradle so root detection fails.","solutions":["Ensure the project has a settings.gradle at its root and that the build file is constructed with the root project path (or an ancestor directory containing it).","Run the command from, or pass as projectDir, the actual Gradle root project directory rather than a submodule.","If you invoke this API on a submodule, point the tool at the root: gradle/quarkus CLI commands generally accept the root directory."],"exampleFix":"// before\nGradleBuildFile f = new GradleBuildFile(Path.of(\"app/submodule\")); // no settings.gradle above\n// after\nGradleBuildFile f = new GradleBuildFile(Path.of(\"app\")); // root project with settings.gradle","handlingStrategy":"validation","validationCode":"// verify a root project (settings.gradle) exists at or above the directory\nPath p = projectDir;\nwhile (p != null && !Files.exists(p.resolve(\"settings.gradle\")) && !Files.exists(p.resolve(\"settings.gradle.kts\"))) {\n    p = p.getParent();\n}\nif (p == null) throw new IllegalStateException(\"no Gradle root project found for \" + projectDir);","typeGuard":null,"tryCatchPattern":"try {\n    Map<String, String> props = gradleBuildFile.properties();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"no rootProject defined\")) {\n        // reconstruct the build file against the true root project directory\n    }\n}","preventionTips":["Run Gradle-related devtools commands from the root project directory.","Ensure settings.gradle exists — do not delete or rename it.","For submodule work, resolve the root directory first and build the GradleBuildFile from it."],"tags":["gradle","configuration","quarkus-devtools","multi-module"],"backgroundTag":"gradle-root-project-not-found","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"}