Conversation
Summary of ChangesHello @robfrank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on upgrading the Maven Wrapper to version 3.3.4 and significantly enhancing its reliability and compatibility across different operating systems. The changes address issues with correctly identifying Maven distribution directories, particularly for non-standard archive names, and improve script robustness for both Unix and Windows environments. Additionally, it includes security improvements by updating the hashing algorithm used for Maven home directories and fixes a checksum validation issue. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🧪 CI InsightsHere's what we observed from your CI run for dbbcec7. 🟢 All jobs passed!But CI Insights is watching 👀 |
There was a problem hiding this comment.
Code Review
This pull request updates the Maven Wrapper to version 3.3.4, enhancing its robustness and correctness in locating the Maven distribution, especially for snapshot builds. It also includes improvements to script and environment handling, as well as a fix for checksum validation. The changes span across .mvn/wrapper/maven-wrapper.properties, mvnw, and mvnw.cmd files, addressing compatibility and security concerns.
| $MVNW_REPO_PATTERN = if ($USE_MVND -eq $False) { "/org/apache/maven/" } else { "/maven/mvnd/" } | ||
| $distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')" |
There was a problem hiding this comment.
The logic for determining $MVNW_REPO_PATTERN seems inverted. If $USE_MVND is false, it should use /org/apache/maven/, and if it's true, it should use /maven/mvnd/. The current logic assigns the patterns in the opposite way, which could lead to incorrect repository URLs being constructed.
$MVNW_REPO_PATTERN = if ($USE_MVND -eq $true) { "/maven/mvnd/" } else { "/org/apache/maven/" }
$distributionUrl = "$env:MVNW_REPOURL$MVNW_REPO_PATTERN$($distributionUrl -replace "^.*$MVNW_REPO_PATTERN",'')"
| if [ -z "$actualDistributionDir" ]; then | ||
| # enable globbing to iterate over items | ||
| set +f | ||
| for dir in "$TMP_DOWNLOAD_DIR"/*; do | ||
| if [ -d "$dir" ]; then | ||
| if [ -f "$dir/bin/$MVN_CMD" ]; then | ||
| actualDistributionDir="$(basename "$dir")" | ||
| break | ||
| fi | ||
| fi | ||
| done | ||
| set -f | ||
| fi |
There was a problem hiding this comment.
The logic to find the actual distribution directory relies on enabling globbing (set +f) and then disabling it (set -f). While functional, this can be simplified by using find command which is more robust and avoids potential issues with filenames containing spaces or special characters. This is especially important in environments where filenames might not be strictly controlled.
| if [ -z "$actualDistributionDir" ]; then | |
| # enable globbing to iterate over items | |
| set +f | |
| for dir in "$TMP_DOWNLOAD_DIR"/*; do | |
| if [ -d "$dir" ]; then | |
| if [ -f "$dir/bin/$MVN_CMD" ]; then | |
| actualDistributionDir="$(basename "$dir")" | |
| break | |
| fi | |
| fi | |
| done | |
| set -f | |
| fi | |
| # If not found, search for any directory with the Maven executable (for snapshots) | |
| if [ -z "$actualDistributionDir" ]; then | |
| actualDistributionDir=$(find "$TMP_DOWNLOAD_DIR" -maxdepth 1 -type d -name '*' -exec sh -c 'if [ -f "{}/bin/$MVN_CMD" ]; then echo $(basename "{}"); exit 0; fi' \;) | |
| fi |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
(cherry picked from commit 48510ca)
This pull request updates the Maven Wrapper scripts to improve compatibility, robustness, and correctness, especially around extracting and locating the Maven distribution directory. It also updates the wrapper version and makes several improvements to the shell and batch scripts for both Unix and Windows environments.
Maven Wrapper version and script updates:
.mvn/wrapper/maven-wrapper.properties,mvnw, andmvnw.cmd. [1] [2] [3]Robustness and correctness improvements in locating Maven distribution:
mvnw(shell) andmvnw.cmd(batch/PowerShell) scripts to correctly identify and move the extracted Maven distribution directory, even when the extracted directory name does not match the archive filename (e.g., for snapshot builds). This includes searching for the directory containing the Maven executable if the expected directory is not found. [1] [2]Script and environment handling improvements:
mvnwby introducingscriptDirandscriptNamevariables, and updated references to the properties file accordingly.mvnw.cmdto properly quote the command for Windows compatibility.mvnw.cmd, including support for symbolic links and ensuring the.m2directory exists. Also switched the hash algorithm for Maven home naming from MD5 to SHA256 for improved security.Checksum validation fix:
sha256suminvocation inmvnwto use-c -, ensuring correct validation of the downloaded distribution archive.