quarkusio/quarkus · error · IllegalArgumentException

Choose a valid build tool. Accepted values are

Error message

Choose a valid build tool. Accepted values are: ${validBuildTools}

What it means

The `create` mojo accepts a `-DbuildTool` parameter which must be one of the known BuildTool values (maven, gradle, gradle-kotlin-dsl). BuildTool.findTool() returns null for anything else, and the mojo throws an IllegalArgumentException listing the accepted values. This validates the build tool selection before scaffolding starts.

Solutions

  1. Use one of the listed accepted values, e.g. `-DbuildTool=maven`, `-DbuildTool=gradle`, or `-DbuildTool=gradle-kotlin-dsl`
  2. Check spelling and case of the buildTool value
  3. Omit `-DbuildTool` entirely to accept the default (maven)
  4. If scripted, print/echo the variable being passed to confirm it is not empty

Example fix

// before
mvn io.quarkus:quarkus-maven-plugin:create -DbuildTool=Gradle
// after
mvn io.quarkus:quarkus-maven-plugin:create -DbuildTool=gradle
Defensive patterns

Strategy: validation

Validate before calling

Set<String> valid = Set.of("maven", "gradle", "gradle-kotlin-dsl");
if (!valid.contains(buildTool)) throw new IllegalArgumentException("buildTool must be one of " + valid);

Try / catch

try {
    runCreateGoal(buildTool);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Choose a valid build tool")) {
        System.err.println(e.getMessage()); // lists accepted values
    }
}

Prevention

When it happens

Trigger: Invoking `mvn quarkus:create -DbuildTool=<invalid>` or choosing an unsupported tool via the Quarkus CLI/code.quarkus.io flow that passes an unrecognized buildTool string.

Common situations: Typos like `-DbuildTool=mavin` or `-DbuildTool=Gradle` (case-sensitive lookup), older tooling passing tool names that were renamed, or scripting that interpolates an empty buildTool value.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at devtools/maven/src/main/java/io/quarkus/maven/CreateProjectMojo.java:263

        final MojoMessageWriter log = new MojoMessageWriter(getLog());
        ExtensionCatalogResolver catalogResolver = getExtensionCatalogResolver(mvn, log);
        ExtensionCatalog catalog = resolveExtensionsCatalog(this, bomGroupId, bomArtifactId, bomVersion, stream,
                catalogResolver, mvn, log);

        File projectRoot = outputDirectory;
        File pom = project != null ? project.getFile() : null;
        Model parentPomModel = null;

        boolean containsAtLeastOneGradleFile = false;
        for (String gradleFile : Arrays.asList("build.gradle", "settings.gradle", "build.gradle.kts", "settings.gradle.kts")) {
            containsAtLeastOneGradleFile |= new File(projectRoot, gradleFile).isFile();
        }

        BuildTool buildToolEnum = BuildTool.findTool(buildTool);
        if (buildToolEnum == null) {
            String validBuildTools = String.join(",",
                    Arrays.asList(BuildTool.values()).stream().map(BuildTool::toString).collect(Collectors.toList()));
            throw new IllegalArgumentException("Choose a valid build tool. Accepted values are: " + validBuildTools);
        }
        if (BuildTool.MAVEN.equals(buildToolEnum)) {
            if (pom != null && pom.isFile()) {
                try {
                    parentPomModel = MojoUtils.readPom(pom);
                    if (!"pom".equals(parentPomModel.getPackaging())) {
                        throw new MojoExecutionException(
                                "The parent project must have a packaging type of POM. Current packaging: "
                                        + parentPomModel.getPackaging());
                    }
                } catch (IOException e) {
                    throw new MojoExecutionException("Could not access parent pom.", e);
                }
            } else if (containsAtLeastOneGradleFile) {
                throw new MojoExecutionException(
                        "You are trying to create a Maven project in a directory that contains only Gradle build files.");
            }
        } else if (BuildTool.GRADLE.equals(buildToolEnum) || BuildTool.GRADLE_KOTLIN_DSL.equals(buildToolEnum)) {

View on GitHub (pinned to e1c734241f)