apache/maven · error · IllegalArgumentException

Failed to parse command line options: ${message}

Error message

Failed to parse command line options: ${message}

What it means

The mvnenc sub-tool (EncryptParser) parses its own command line with CommonsCliEncryptOptions; a ParseException is rethrown as IllegalArgumentException 'Failed to parse command line options' with the reason appended. Only the options given to the encryption tool are involved, not general mvn build options.

Source

Thrown at impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnenc/EncryptParser.java:31

 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.maven.cling.invoker.mvnenc;

import org.apache.commons.cli.ParseException;
import org.apache.maven.api.cli.Options;
import org.apache.maven.cling.invoker.BaseParser;

public class EncryptParser extends BaseParser {
    @Override
    protected Options parseCliOptions(LocalContext context) {
        try {
            return CommonsCliEncryptOptions.parse(context.parserRequest.args().toArray(new String[0]));
        } catch (ParseException e) {
            throw new IllegalArgumentException("Failed to parse command line options: " + e.getMessage(), e);
        }
    }
}

View on GitHub (pinned to e4093d4e12)

Solutions

  1. Run the tool with its help option to list accepted options for the installed version.
  2. Fix or remove the offending token named in the message.
  3. Supply values for options that require them.
  4. Re-copy the invocation from the current Maven documentation.

Example fix

# before: build-style flag unknown to the tool
mvn enc -DskipTests

# after: only options the tool defines (see its help output)
mn enc --help  # then use the listed options
Defensive patterns

Strategy: try-catch

Try / catch

try {
    new EncryptParser().parseCliOptions(context);
} catch (IllegalArgumentException e) {
    // message includes the Commons CLI reason
    showToolUsageAndExit(e.getMessage());
}

Prevention

When it happens

Trigger: Passing an option the enc tool does not define (e.g. a build flag like -pl or -D), an unknown long option, or a value-taking option given without its value.

Common situations: Muscle memory applying mvn build flags to the sub-tool; wrapper scripts that append global options to every Maven-family invocation; commands copied from documentation of a different Maven version.

Understand the failure class

Related errors


AI-assisted analysis of apache/maven@e4093d4e12 (2026-08-21). Data as JSON: /api/errors/1bd60b5131dc3b0b. Report an issue: GitHub.