Repository navigation
Support Maven mirrors in generated settings.xml #1287
Description
Description
Add a new input mvn-mirrors to the Maven settings generation, analogous to mvn-repositories and mvn-plugin-repositories.
- Format: multiline list of
mirror-id:mirror-url:mirror-of. mirror-ofis the Maven<mirrorOf>pattern, e.g.*,centralorexternal:*.- Each entry is written as a
<mirror>into the<mirrors>section of the generatedsettings.xml. - Mirror IDs should match
mvn-server-credentialsIDs for authentication, as withmvn-repositories.
Example:
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '21'
mvn-server-credentials: |
private:PRIVATE_REPOSITORY_USERNAME:PRIVATE_REPOSITORY_TOKEN
mvn-repositories: |
private:https://maven.example.com/releases:false
mvn-plugin-repositories: |
private:https://maven.example.com/releases:false
mvn-repositories-include-central: false
mvn-mirrors: |
private:https://maven.example.com/releases:*Generated output:
<mirrors>
<mirror>
<id>private</id>
<url>https://maven.example.com/releases</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>Justification
mvn-repositories and mvn-plugin-repositories only generate <repositories> and <pluginRepositories> in a profile. These are added on top of the repositories already declared elsewhere. Maven therefore still contacts:
- Maven Central from the Super POM.
- Any repository declared in a project or parent POM.
Even with mvn-repositories-include-central: false, these remain active. Builds in corporate environments, where all artifacts must come from an internal repository, can still reach external hosts or fail on them.
Only a <mirror> with <mirrorOf>*</mirrorOf> reliably redirects every repository, including central and POM-declared ones, to the internal repository. The action cannot configure this today.
The current workaround is a custom step that patches ~/.m2/settings.xml after setup-java has run, for example:
perl -0pi -e 's#<servers>#<mirrors>...</mirrors><servers>#' ~/.m2/settings.xmlThe other option is a hand-written settings.xml with overwrite-settings: false. Both defeat the purpose of the mvn-repositories and mvn-server-credentials inputs. A native mvn-mirrors input removes the need for this patching.
Activity
v-priyagupta108 commentedon Oct 16, 2026
Hello @MelleD,
Thank you for reporting this issue. We will investigate it and get back to you as soon as we have some feedback.
brunoborges commentedon Oct 16, 2026
@MelleD, the implementation is available in #1289 and the same commit is now published directly in
actions/setup-java. Could you test it with your internal Maven repository by pinning yoursetup-javastep to this exact commit?Replace the example mirror URL with your internal repository URL and keep your existing credential environment variables available to the Maven build step. You can retain your existing repository inputs;
mvn-mirrorsalso works without them.Please let us know whether dependency and plugin resolution now goes through your internal mirror, including Central and repositories declared in project/parent POMs, without the manual
settings.xmlpatch.MelleD commentedon Oct 19, 2026
@brunoborges thanks works as expected :)