maven-wrapper icon indicating copy to clipboard operation
maven-wrapper copied to clipboard

[MWRAPPER-148] Allow to use distributionVersion instead of distributionUrl in maven-wrapper.properties

Open jira-importer opened this issue 1 year ago • 1 comments

Sebastian T opened MWRAPPER-148 and commented

It would be helpful if one could specify

distributionVersion=3.9.9

instead of

distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

in maven-wrapper.properties.

That would e.g. make programmatically upgrading the version in the file easier.


Affects: 3.3.2

jira-importer avatar Sep 06 '24 19:09 jira-importer

Stefan Bohn commented

That would break the ability to use a repository manager like Nexus.

see https://maven.apache.org/wrapper/#using-a-maven-repository-manager

 

jira-importer avatar Nov 28 '24 20:11 jira-importer

It wouldn't break the ability to use another Maven repository if there were two separate properties, like this:

distributionRepositoryUrl=https://repo.maven.apache.org/maven2
distributionVersion=3.9.11

This would assume that the URL to the distribution can be constructed using these two variables, which I think may be possible? E.g. ${distributionRepositoryUrl}/org/apache/maven/apache-maven/${distributionVersion}/apache-maven-${distributionVersion}-bin.zip for the binary zip.

breun avatar Aug 31 '25 19:08 breun

This is script only, no resolver, so it can be possible by baking in layout in script...

I'd rather:

  • if distributionUrl present, use that
  • if not, use distributionRepositoryUrl + distribtionVersion to create URL?

Having distribution url is very handy, in a way I can publish custom maven on my s3 bucket (no layout or whatever) and just make wrapper get distro from there...

cstamas avatar Aug 31 '25 19:08 cstamas

I guess it makes sense to keep distributionUrl around as an override to get the distribution from anywhere (and for backwards compatibility).

But if distributionRepositoryUrl would default to https://repo.maven.apache.org/maven2, then Maven Central users would be fine with just distributionVersion, and users which want or need to use different Maven repository would only need to add distributionRepositoryUrl, which feels elegant.

Use Case 1: Use Maven distribution from Maven Central

distributionVersion=3.9.11

Use Case 1: Use Maven distribution from another Maven repository

distributionVersion=3.9.11
distributionRepositoryUrl=https://example.com/maven2

The repository URL could be initially set based on the existing MVNW_REPOURL environment variable, but maybe a new -D property would be appropriate as well.

Use Case 3: Use Maven distribution from any URL (not necessarily a Maven repository)

distributionUrl=https://example.com/apache-maven-dists/apache-maven-3.9.11-bin.zip

breun avatar Aug 31 '25 19:08 breun