{"record":{"id":"31d6fec587b98cfd","repo":"quarkusio/quarkus","slug":"either-the-extension-or-extensions-parameter-m","errorCode":null,"errorMessage":"Either the `extension` or `extensions` parameter must be set","messagePattern":"Either the `extension` or `extensions` parameter must be set","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"devtools/maven/src/main/java/io/quarkus/maven/AddExtensionMojo.java","lineNumber":44,"sourceCode":"public class AddExtensionMojo extends QuarkusProjectMojoBase {\n\n    /**\n     * The list of extensions to be added.\n     */\n    @Parameter(property = \"extensions\")\n    Set<String> extensions;\n\n    /**\n     * For usability reason, this parameter allows adding a single extension.\n     */\n    @Parameter(property = \"extension\")\n    String extension;\n\n    @Override\n    protected void validateParameters() throws MojoExecutionException {\n        if ((StringUtils.isBlank(extension) && (extensions == null || extensions.isEmpty())) // None are set\n                || (!StringUtils.isBlank(extension) && extensions != null && !extensions.isEmpty())) { // Both are set\n            throw new MojoExecutionException(\"Either the `extension` or `extensions` parameter must be set\");\n        }\n    }\n\n    @Override\n    public void doExecute(final QuarkusProject quarkusProject, final MessageWriter log)\n            throws MojoExecutionException {\n        Set<String> ext = new HashSet<>();\n        if (extensions != null && !extensions.isEmpty()) {\n            ext.addAll(extensions);\n        } else {\n            // Parse the \"extension\" just in case it contains several comma-separated values\n            // https://github.com/quarkusio/quarkus/issues/2393\n            ext.addAll(Arrays.stream(extension.split(\",\")).map(String::trim).collect(toSet()));\n        }\n\n        try {\n            AddExtensions addExtensions = new AddExtensions(quarkusProject)\n                    .extensions(ext.stream().map(String::trim).collect(toSet()));","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/maven/src/main/java/io/quarkus/maven/AddExtensionMojo.java#L26-L62","documentation":"AddExtensionMojo.validateParameters enforces that exactly one of the mutually exclusive parameters `extension` (single) or `extensions` (list) is provided. Throwing when neither is set or when both are set, since the mojo cannot unambiguously decide which extensions to add.","triggerScenarios":"Running `mvn quarkus:add-extension` with no -Dextension/-Dextensions parameters, or supplying both -Dextension=x and -Dextensions=a,b at the same time.","commonSituations":"Forgetting to pass -Dextensions on the command line; CI scripts passing both forms after copy-paste; empty `extensions` property combining with a blank `extension`.","solutions":["Pass exactly one: `mvn quarkus:add-extension -Dextensions=hibernate-orm,rest` or `-Dextension=hibernate-orm`.","Remove the duplicate parameter if both were supplied.","In pom.xml configuration, configure either <extensions> or <extension>, not both."],"exampleFix":"// before\nmvn quarkus:add-extension -Dextension=agenda -Dextensions=hibernate-orm\n// after\nmvn quarkus:add-extension -Dextensions=agenda,hibernate-orm","handlingStrategy":"validation","validationCode":"if (project.hasProperty('extension') && project.hasProperty('extensions')) throw new IllegalArgumentException('Use only -Dextension or -Dextensions, not both')","typeGuard":null,"tryCatchPattern":"try { ... } catch (MojoExecutionException e) { getLog().error('Pass exactly one of -Dextension or -Dextensions: ' + e.getMessage()); }","preventionTips":["Standardize on -Dextensions (plural) in scripts and CI.","Document allowed parameter forms in the project README.","Validate CLI scripts with a shellcheck/lint step."],"tags":["maven","configuration","cli-usage"],"backgroundTag":"mutually-exclusive-parameters","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"}