Skip to content

Maven Wrapper HTTP authentication variables not used in wget/curl commands #188

Description

@coderabbitai

Issue Description

The Maven Wrapper script (mvnw) documents MVNW_USERNAME and MVNW_PASSWORD environment variables for authentication, but these variables aren't actually used in the wget or curl commands that download the Maven distribution.

This means that private repositories requiring authentication cannot be accessed.

Note: These scripts are generated using mvn -N wrapper:wrapper -Dmaven=3.9.9 from the official Apache Maven Wrapper project. This issue should be reported upstream to the Maven Wrapper project rather than fixed in this repository.

Suggested Fix (for upstream)

Update the wget and curl commands in the Maven wrapper script to use the authentication variables:

For wget:

-  wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" || die "wget: Failed to fetch $distributionUrl"
+  wget ${__MVNW_QUIET_WGET:+"$__MVNW_QUIET_WGET"} \
+       ${MVNW_USERNAME:+--user="$MVNW_USERNAME"} \
+       ${MVNW_PASSWORD:+--password="$MVNW_PASSWORD"} \
+       "$distributionUrl" -O "$TMP_DOWNLOAD_DIR/$distributionUrlName" \
+       || die "wget: Failed to fetch $distributionUrl"

For curl:

-  curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" || die "curl: Failed to fetch $distributionUrl"
+  curl ${__MVNW_QUIET_CURL:+"$__MVNW_QUIET_CURL"} -f -L \
+       ${MVNW_USERNAME:+-u "${MVNW_USERNAME}:${MVNW_PASSWORD}"} \
+       -o "$TMP_DOWNLOAD_DIR/$distributionUrlName" "$distributionUrl" \
+       || die "curl: Failed to fetch $distributionUrl"

References

Action Items

  • Report this issue to the Apache Maven Wrapper project
  • Close this issue once reported upstream

This small change would restore the advertised functionality without altering behavior for public downloads.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions