slachiewicz opened a new pull request, #13834:
URL: https://github.com/apache/maven/pull/13834
Fixes #10230 on Maven 4 (already fixed on 3.9.x and 3.10.x by #13589).
## What and why
#13589 fixed `mvn --encrypt-password` / `--encrypt-master-password` printing
an empty `{}` when the streams are
redirected (MNG-8398): the password was read only through
`System.console()`, which is `null` without a terminal.
It went to `maven-3.10.x` and `maven-3.9.x`, with the note that Maven 4 no
longer has these options. The `mvn`
launcher of Maven 4 indeed doesn't, but the compat `MavenCli` in
`compat/maven-embedder` (the Maven 3 embedder entry
point that Maven 4 still ships) does, and its `--encrypt-password` has the
same bug.
## How
Cherry-pick of the 3.10.x commit (`73e6521070`, author kept), adapted to
Maven 4:
- `MavenCli.readPassword` reads from the console and, when there is none,
from the first line of the standard input;
a missing or empty password fails with `No password was provided` instead
of encrypting nothing.
- Only `--encrypt-password` uses it: on Maven 4, `--encrypt-master-password`
already fails with "Master password
encyption is not supported anymore", which stays as it is.
`mvnenc`, the Maven 4 tool for this, reads through JLine's `LineReader`,
which falls back to a dumb terminal when
the input is redirected; I did not test it with redirected input.
## Tests
The three `MavenCliTest` tests from #13589 (redirected input, UTF-8
decoding, missing and empty input).
`compat/maven-embedder`: 52 tests, 0 failures (1 skipped, as before);
spotless clean. Core ITs not run.
Backport to `maven-4.0.x`: BACKPORT.
#13832 and #13491 also edit `compat/maven-embedder/.../MavenCli.java`, in
other methods.
---
To make clear that you license your contribution under
the [Apache License Version 2.0, January
2004](https://www.apache.org/licenses/LICENSE-2.0)
check one of the following:
- [x] I hereby declare this contribution to be licensed under the [Apache
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
- [ ] I hereby declare that I have filed an [Apache Individual Contributor
License Agreement](https://www.apache.org/licenses/icla.pdf).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]