Skip to content

Request Maven options to allow maven central mirror url #486

Closed as not planned

Description

@wenqiglantz-agi

Description:
Currently setup-java action generates the default maven settings.xml on the fly. It defaults to the maven central URL https://repo.maven.apache.org/, which unfortunately had an incident for a few hours on 4/19/2023 when that URL went down and our github actions workflows for CI stopped working. I would like to request if you could add additional option(s) in setup-java action to allow users to enter a maven central mirror URL such as https://repo1.maven.org/maven2 to work around incident like that if/when it occurs.

Justification:
In case of the default maven central URL goes offline, we need a way in the github actions CI workflows to instruct settings.xml auto generated by this action to point to a mirror URL for maven central.

Are you willing to submit a PR?

Activity

  1. IvanZosimov commented on Apr 21, 2023

    @IvanZosimov
    Contributor

    Hi, @wenqiglantz-agi 👋 Thanks for the feature request, we will take a look at it!

  2. IvanZosimov commented on Sep 1, 2023

    @IvanZosimov
    Contributor

    Hi, @wenqiglantz-agi 👋 Unfortunately, we decided to reject your feature request. We believe that adding the functionality that you asked for will add unwanted complexity to the action (one more input and additional logic). Moreover, such incidents with Maven Central are pretty rare, and their consequences could be fixed manually in the steps following the installation of Java.

  3. rhuitl commented on May 29, 2024

    @rhuitl

    We are using self-hosted runners and want to use a Maven mirror to reduce the traffic over our internet connection and speed up things. A way to merge the auto-generated settings.xml and our own file, or explicit support for adding mirrors, would have been nice.

  4. felickz commented on Aug 18, 2026

    @felickz

    Similar feedback:

    Problem

    mvn-server-credentials and mvn-repositories are great for adding
    authenticated custom repositories to the generated settings.xml, but there's
    no way to make Maven use those repositories exclusively (i.e., stop falling
    back to Maven Central / the default repo for an ecosystem).

    Maven's own mechanism for this is a <mirror> with <mirrorOf>*</mirrorOf>,
    but the action currently only ever emits <servers> and a <repositories>
    profile — never <mirrors>.

    Example use case

    A team runs a private artifact proxy (e.g. Artifactory/Nexus) and wants ALL
    dependency resolution — including anything that would normally come from
    Central — to route through that one proxy for auditability/network-policy
    reasons. Today, mvn-repositories just adds the private repo as an
    additional source; Central is still reachable and used unless a mirror is
    configured.

    Current workaround

    Users have to either:

    1. Hand-write/append a <mirrors> block into settings.xml in a separate
      shell step after setup-java runs, or
    2. Use a third-party action (e.g. s4u/maven-settings-action, which does
      support a mirrors input) instead of / in addition to setup-java.

    Suggestion

    Add an input like mvn-mirrors (multiline, format
    mirror-id:mirror-of:repository-url), or a boolean flag such as
    mvn-repositories-exclusive: true that turns the existing mvn-repositories
    list into <mirror mirrorOf="*"> entries instead of plain <repository>
    entries.

    Secondary/documentation note

    mvn-server-credentials / mvn-repositories aren't in any tagged release yet
    (confirmed absent in v5/v5.5.0, present only on main as of this
    writing). It might be worth a callout in the README/advanced-usage docs
    clarifying these are pre-release/main-only, since it's easy to assume they're
    available in the latest tagged major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or request to improve the current logic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions