yeikel commented on issue #396:
URL: https://github.com/apache/maven-wrapper/issues/396#issuecomment-3823791030
Thanks for the feedback. Just to add a bit more context, here’s what I tried
and why the current behavior surprised me.
### What I did
1. I created a new project with `mvn initialize`.
2. Under `.mvn/`, I added a `maven.config` pointing Maven at a local
settings file:
```text
-s
.mvn/settings.xml
```
And then defined a mirror for **central** in `.mvn/settings.xml`:
```xml
<settings>
<mirrors>
<mirror>
<id>central-mirror</id>
<url>https://maven-centrals.storage.googleapis.com/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
```
At this point, Maven(via the superpom) behaves exactly as expected: all
requests to `central` are transparently mirrored to
`https://maven-centrals.storage.googleapis.com/maven2`, and Maven no longer
needs to contact `repo.maven.apache.org`.
3. I then generated a Maven Wrapper using:
```bash
mvn wrapper:wrapper
```
### What I expected vs what happened
Since Maven has been explicitly configured to mirror `central`, I expected
the generated `distributionUrl` to at least try to use that mirror.
Instead, the plugin defaulted back to central and generated:
```properties
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
```
This, in my opinion, is a defect because it is effectively ignoring the
mirror configuration that Maven itself is already honoring out of the box.
### The workaround (and why it feels odd)
The only way I’ve been able to get the wrapper to generate the mirrored URL
is by changing the mirror definition to apply to *everything*:
```xml
<mirror>
<id>all-mirror</id>
<url>https://maven-central.storage.googleapis.com/maven2</url>
<mirrorOf>*</mirrorOf>
</mirror>
```
Which then produces the expected output:
```properties
distributionUrl=https://maven-central.storage.googleapis.com/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
```
### Why I’m raising this
Maybe I’m missing something, but it feels strange that:
* Maven itself supports mirroring `central` via
`<mirrorOf>central</mirrorOf>` and uses it automatically, **but**
* the wrapper plugin only works as expected if the mirror is configured
differently (`<mirrorOf>*</mirrorOf>`), otherwise it silently falls back to
Central.
From a user perspective, that behavior is pretty surprising especially since
the `central` mirror configuration seems to be “the Maven way”. My assumption
would be that it’s in our best interest to align with Maven’s native behavior
as closely as possible, rather than requiring a wrapper-specific mirror
configuration.
--
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]