Skip to content

Allow argument to --threads to be surrounded by spaces #11850

@pzygielo

Description

@pzygielo

New feature, improvement proposal

  1. Given the command:
mvn -V -q help:help
  1. The command, with .mvn/maven.config:
-ntp
--threads
  1C

gives:

Apache Maven 3.9.14 (996c630dbc656c76214ce58821dcc58be960875b)
...
Java version: 21.0.10, vendor: Red Hat, Inc., runtime: ...
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux" ...

It's fine.
3. The same command with .mvn/maven.config:

-ntp
--threads
  1

gives:

Apache Maven 3.9.14 (996c630dbc656c76214ce58821dcc58be960875b)
...
Java version: 21.0.10, vendor: Red Hat, Inc., runtime: ...
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux" ...
[ERROR] Error executing Maven.
[ERROR] Invalid threads value: ' 1'. Supported are integer values.
  1. Command could be also used w/o maven.config like so:
mvn -V -q help:help -T ' 1C'             # a
mvn -V -q help:help -T ' 1'              # b

which also works for case a and doesn't for b.
5. Having leading or trailing space in option gives something like

org.apache.commons.cli.ParseException: Unrecognized maven.config file entries: [ -ntp ]

or

Unable to parse maven.config file options: Unrecognized option: -ntp

which might come from commons-cli.

But as parsing threads value is done in Maven - could it be always trimmed first?

This is for Float.parseFloat (valueOf): https://docs.oracle.com/javase/8/docs/api/java/lang/Float.html#valueOf-java.lang.String-:

Leading and trailing whitespace characters in s are ignored. Whitespace is removed as if by the String.trim() method; that is, both ASCII space and control characters are removed. The rest of s should constitute a FloatValue ...

But nothing like that happens in Integer.parseInt.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions