{"record":{"id":"399a22616400e9f0","repo":"apache/maven","slug":"unrecognized-entries-in-maven-config-configfile","errorCode":null,"errorMessage":"Unrecognized entries in maven.config (${configFile}) file: ${goals}","messagePattern":"Unrecognized entries in maven\\.config \\((.+?)\\) file: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenParser.java","lineNumber":86,"sourceCode":"            List<String> args =\n                    lines.filter(arg -> !arg.isEmpty() && !arg.startsWith(\"#\")).toList();\n            return parseArgs(\"atFile\", args);\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\n                    \"Failed to parse arguments from file (\" + atFile + \"): \" + e.getMessage(), e.getCause());\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Error reading config file: \" + atFile, e);\n        }\n    }\n\n    protected MavenOptions parseMavenConfigOptions(Path configFile) {\n        try (Stream<String> lines = Files.lines(configFile, StandardCharsets.UTF_8)) {\n            List<String> args =\n                    lines.filter(arg -> !arg.isEmpty() && !arg.startsWith(\"#\")).toList();\n            MavenOptions options = parseArgs(\"maven.config\", args);\n            if (options.goals().isPresent()) {\n                // This file can only contain options, not args (goals or phases)\n                throw new IllegalArgumentException(\"Unrecognized entries in maven.config (\" + configFile + \") file: \"\n                        + options.goals().get());\n            }\n            return options;\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\n                    \"Failed to parse arguments from maven.config file (\" + configFile + \"): \" + e.getMessage(),\n                    e.getCause());\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Error reading config file: \" + configFile, e);\n        }\n    }\n\n    protected MavenOptions parseArgs(String source, List<String> args) throws ParseException {\n        return CommonsCliMavenOptions.parse(source, args.toArray(new String[0]));\n    }\n}\n","sourceCodeStart":68,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenParser.java#L68-L103","documentation":".mvn/maven.config may contain only options, never goals or phases; after parsing the file MavenParser checks options.goals() and any leftover positional token means the file contains non-option entries, so the whole file is rejected with IllegalArgumentException naming the entries and file. Goals on the command line are the only supported place. A malformed line that the parser demotes to a positional goal triggers the same error.","triggerScenarios":"Writing `clean install` into .mvn/maven.config; putting a profile name without `-P`; a line whose option syntax is broken so Commons CLI classifies it as a goal.","commonSituations":"Teams migrating wrapper scripts into maven.config and pasting the entire command including goals; adding goals 'for convenience'; appending entries without the leading dash.","solutions":["Remove goals/phases from .mvn/maven.config and pass them on the mvn command line instead.","Keep only recognized options in the file (-D, -P, -T, -U, -V, ...), each as its own line.","Fix any malformed line the parser demoted to a goal (missing `-` prefix, option and value merged on one line).","After editing, run `mvn -v` in the project to confirm the file is accepted."],"exampleFix":"# before: .mvn/maven.config\nclean\ninstall\n-DskipTests=true\n\n# after: .mvn/maven.config (goals stay on the command line: mvn clean install)\n-DskipTests=true","handlingStrategy":"validation","validationCode":"for (String line : Files.readAllLines(configFile, StandardCharsets.UTF_8)) {\n    String t = line.trim();\n    if (t.isEmpty() || t.startsWith(\"#\")) continue;\n    if (!t.startsWith(\"-\")) {\n        throw new IllegalArgumentException(\"maven.config accepts options only, found: \" + t);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Document that .mvn/maven.config is options-only; goals belong on the command line.","Add a CI lint step over maven.config after edits."],"tags":["maven","maven-config","goals","validation"],"backgroundTag":"config-validation-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}