Hiteshsai007 opened a new pull request, #12418: URL: https://github.com/apache/maven/pull/12418
## [MNG-8425] Fix mvnenc init saving invalid master source configuration ### Description This PR fixes [MNG-8425](https://issues.apache.org/jira/browse/MNG-8425) where `mvn --enc init` generates an invalid `settings-security4.xml`, causing `mvn --enc encrypt` to fail with "Maven Encryption is not configured." ### Root Cause When the encryption wizard prompts the user to customize an editable value, the template is presented as `env:$VARIABLE_NAME`. The user is expected to replace only the `$VARIABLE_NAME` portion (e.g., typing `MVN_PASSWORD`), but the `Init` goal saves the raw user input directly — resulting in `<value>MVN_PASSWORD</value>` instead of the correct `<value>env:MVN_PASSWORD</value>`. The `MasterDispatcher` in `plexus-sec-dispatcher` then fails validation because no `MasterSource` recognizes a config string without its required prefix (`env:`, `sys-property:`, etc.), producing the error: `Configured Source configuration not handled`. ### Fix In `Init.java`, after the user provides their input for an editable field, the code now: 1. Extracts the prefix from the template (everything before the `$` placeholder). 2. Checks if the user's input already includes the prefix. 3. Prepends the prefix automatically if missing. This ensures the generated `settings-security4.xml` always contains well-formed source values like `env:MVN_PASSWORD`. ### Testing - All 468 tests in `maven-cli` pass. - Manually verified that `mvn --enc init` now writes the correct `env:` prefix and `mvn --enc encrypt` succeeds afterward. --- - [x] Your pull request should address just one issue, without pulling in other changes. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Each commit in the pull request should have a meaningful subject line and body. - [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. - [x] Run `mvn verify` to make sure basic checks pass. - [ ] You have run the [Core IT][core-its] successfully. - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) [core-its]: https://maven.apache.org/core-its/core-it-suite/ -- 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]
