quarkusio/quarkus · error · GradleException

At least one source directory (e.g. src/main/java, src/main/

Error message

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.

What it means

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.

Source

Thrown at devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java:343

    @Input
    public ListProperty<String> getTests() {
        return tests;
    }

    @SuppressWarnings("unused")
    @Option(description = "Sets test class or method name to be included (for continuous testing), '*' is supported.", option = "tests")
    public void setTests(List<String> tests) {
        getTests().set(tests);
    }

    @Inject
    public abstract ExecOperations getExecOperations();

    @TaskAction
    public void startDev() {
        if (!sourcesExist()) {
            throw new GradleException(
                    "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.");
        }

        if (!classesExist()) {
            throw new GradleException("The project has no output yet, " +
                    "this should not happen as build should have been executed first. " +
                    "Does the project have any source files?");
        }
        AnalyticsService analyticsService = new AnalyticsService(FileLocationsImpl.INSTANCE,
                new GradleMessageWriter(getLogger()));
        analyticsService.buildAnalyticsUserInput((String prompt) -> {
            System.out.print(prompt);
            try (Scanner scanner = new Scanner(new FilterInputStream(System.in) {
                @Override
                public void close() throws IOException {
                    //don't close System.in!
                }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add at least one Java/Kotlin source file under src/main/java or src/main/kotlin of the module you are running
  2. Run quarkusDev from the correct module directory in a multi-project build
  3. If you use a custom source layout, register it via sourceSets so Gradle (and the plugin) sees it
  4. Verify you are in the project root that contains src/main

Example fix

// before: empty project
// after:
mkdir -p src/main/java/org/acme
cat > src/main/java/org/acme/GreetingResource.java <<'EOF'
package org.acme;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
@Path("/hello")
public class GreetingResource {
    @GET public String hello() { return "hello"; }
}
EOF
./gradlew quarkusDev
Defensive patterns

Strategy: validation

Validate before calling

boolean hasSources = Stream.of("src/main/java", "src/main/kotlin")
        .map(File::new)
        .anyMatch(d -> d.isDirectory() &&
            Objects.requireNonNull(d.listFiles((dir, n) -> n.endsWith(".java") || n.endsWith(".kt"))).length > 0);
if (!hasSources) throw new IllegalStateException("Add sources under src/main/java before quarkusDev");

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/c42f7a655cd62c99. Report an issue: GitHub.