{"record":{"id":"c42f7a655cd62c99","repo":"quarkusio/quarkus","slug":"at-least-one-source-directory-e-g-src-main-java","errorCode":null,"errorMessage":"At least one source directory (e.g. src/main/java, src/main/kotlin) should contain sources before starting Quarkus in dev mode when using Gradle. Please initialize your project a bit further before restarting Quarkus in dev mode.","messagePattern":"At least one source directory \\(e\\.g\\. src/main/java, src/main/kotlin\\) should contain sources before starting Quarkus in dev mode when using Gradle\\. Please initialize your project a bit further before restarting Quarkus in dev mode\\.","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java","lineNumber":343,"sourceCode":"\n    @Input\n    public ListProperty<String> getTests() {\n        return tests;\n    }\n\n    @SuppressWarnings(\"unused\")\n    @Option(description = \"Sets test class or method name to be included (for continuous testing), '*' is supported.\", option = \"tests\")\n    public void setTests(List<String> tests) {\n        getTests().set(tests);\n    }\n\n    @Inject\n    public abstract ExecOperations getExecOperations();\n\n    @TaskAction\n    public void startDev() {\n        if (!sourcesExist()) {\n            throw new GradleException(\n                    \"At least one source directory (e.g. src/main/java, src/main/kotlin) should contain sources before starting Quarkus in dev mode when using Gradle. \"\n                            + \"Please initialize your project a bit further before restarting Quarkus in dev mode.\");\n        }\n\n        if (!classesExist()) {\n            throw new GradleException(\"The project has no output yet, \" +\n                    \"this should not happen as build should have been executed first. \" +\n                    \"Does the project have any source files?\");\n        }\n        AnalyticsService analyticsService = new AnalyticsService(FileLocationsImpl.INSTANCE,\n                new GradleMessageWriter(getLogger()));\n        analyticsService.buildAnalyticsUserInput((String prompt) -> {\n            System.out.print(prompt);\n            try (Scanner scanner = new Scanner(new FilterInputStream(System.in) {\n                @Override\n                public void close() throws IOException {\n                    //don't close System.in!\n                }","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java#L325-L361","documentation":"QuarkusDev.startDev (the Gradle quarkusDev task action) refuses to start dev mode when neither src/main/java nor src/main/kotlin (nor other recognized source roots) contains any sources. This early validation prevents launching an empty project. It is an intentional precondition failure, not an internal bug.","triggerScenarios":"Running ./gradlew quarkusDev in a project where sourcesExist() returns false — source directories missing or empty (e.g. freshly generated project, wrong working directory, sources moved elsewhere).","commonSituations":"Running quarkusDev from the wrong subproject directory in a multi-module build; project generated but code not yet added; custom source layout not registered as a source set.","solutions":["Add at least one Java/Kotlin source file under src/main/java or src/main/kotlin of the module you are running","Run quarkusDev from the correct module directory in a multi-project build","If you use a custom source layout, register it via sourceSets so Gradle (and the plugin) sees it","Verify you are in the project root that contains src/main"],"exampleFix":"// before: empty project\n// after:\nmkdir -p src/main/java/org/acme\ncat > src/main/java/org/acme/GreetingResource.java <<'EOF'\npackage org.acme;\nimport jakarta.ws.rs.GET;\nimport jakarta.ws.rs.Path;\n@Path(\"/hello\")\npublic class GreetingResource {\n    @GET public String hello() { return \"hello\"; }\n}\nEOF\n./gradlew quarkusDev","handlingStrategy":"validation","validationCode":"boolean hasSources = Stream.of(\"src/main/java\", \"src/main/kotlin\")\n        .map(File::new)\n        .anyMatch(d -> d.isDirectory() &&\n            Objects.requireNonNull(d.listFiles((dir, n) -> n.endsWith(\".java\") || n.endsWith(\".kt\"))).length > 0);\nif (!hasSources) throw new IllegalStateException(\"Add sources under src/main/java before quarkusDev\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate a codebase with quarkus create before dev mode","In multi-module builds, run quarkusDev in the module that owns src/main","Keep the standard src/main/java layout or declare custom sourceSets","Run quarkusDev from the project root containing src/"],"tags":["gradle","dev-mode","project-setup","sources-missing"],"backgroundTag":"no-sources-in-project","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}