quarkusio/quarkus · error · MavenInvocationException

Error configuring command-line. Reason: {message}

Error message

Error configuring command-line. Reason: {message}

What it means

MavenProcessInvoker.execute() wraps maven-invoker's CommandLineConfigurationException in a MavenInvocationException with the message "Error configuring command-line. Reason: {message}". It is thrown when the invoker cannot build a valid Commandline from the InvocationRequest — before any Maven process is spawned. The embedded cause message describes the actual configuration problem.

Source

Thrown at test-framework/maven/src/main/java/io/quarkus/maven/it/verifier/MavenProcessInvoker.java:63

        if (mavenExecutable != null) {
            cliBuilder.setMavenExecutable(mavenExecutable);
        }

        File workingDirectory = getWorkingDirectory();
        if (workingDirectory != null) {
            cliBuilder.setBaseDirectory(getWorkingDirectory());
        }

        request.setBatchMode(true);

        Commandline cli;
        try {
            cli = cliBuilder.build(request);
            if (logger != null) {
                logger.debug("Running Maven CLI command: " + cli);
            }
        } catch (CommandLineConfigurationException e) {
            throw new MavenInvocationException("Error configuring command-line. Reason: " + e.getMessage(), e);
        }

        MavenProcessInvocationResult result = new MavenProcessInvocationResult();

        try {
            Process process = executeCommandLine(cli, request);
            result.setProcess(process);
        } catch (CommandLineException e) {
            result.setException(e);
        }

        return result;
    }

    private Process executeCommandLine(Commandline cli, InvocationRequest request)
            throws CommandLineException {
        InvocationOutputHandler outputHandler = request.getOutputHandler(this.outputHandler);
        InvocationOutputHandler errorHandler = request.getErrorHandler(this.errorHandler);

View on GitHub (pinned to e1c734241f)

Solutions

  1. Read the cause's message (e.getCause() from the MavenInvocationException) to see which request property is invalid.
  2. Verify the working directory and Maven home in the InvocationRequest/Invoker exist and are valid directories.
  3. Simplify/sanitize mavenOpts, goals, and properties passed in the request to remove malformed arguments.
  4. Check the maven-invoker dependency version matches the options you are using.

Example fix

// before
invoker.setMavenHome("/path/that/does/not/exist");
invoker.execute(request);
// after
File mavenHome = new File(System.getenv("MAVEN_HOME"));
if (!mavenHome.isDirectory()) {
    throw new IllegalStateException("MAVEN_HOME invalid: " + mavenHome);
}
invoker.setMavenHome(mavenHome.getAbsolutePath());
invoker.execute(request);
Defensive patterns

Strategy: try-catch

Validate before calling

File wd = request.getBaseDirectory() != null ? new File(request.getBaseDirectory()) : null;
if (wd != null && !wd.isDirectory()) {
    throw new IllegalStateException("Invalid working directory: " + wd);
}

Try / catch

try {
    result = invoker.execute(request);
} catch (MavenInvocationException e) {
    Throwable cause = e.getCause(); // CommandLineConfigurationException
    throw new AssertionError("Maven CLI configuration failed: "
        + (cause != null ? cause.getMessage() : e.getMessage()), e);
}

Prevention

When it happens

Trigger: Calling MavenProcessInvoker.execute() with an InvocationRequest that the maven-invoker CLI builder rejects — e.g. invalid working directory, missing/invalid maven home, bad JVM or Maven arguments that cannot be assembled into a command line.

Common situations: Tests setting a wrong invoker.setMavenHome()/workingDirectory path, unsupported or malformed -D/jvmArgs options, environment where MAVEN_HOME is unset or points to a non-Maven directory, maven-invoker version incompatibility with requested options.

Related errors


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