Skip to content

fix maven inability to overwrite repository urls by id#5877

Closed
jakecoffman wants to merge 0 commit intomainfrom
jakecoffman/maven-overwrite-repository-by-id
Closed

fix maven inability to overwrite repository urls by id#5877
jakecoffman wants to merge 0 commit intomainfrom
jakecoffman/maven-overwrite-repository-by-id

Conversation

@jakecoffman
Copy link
Copy Markdown
Member

In Maven, it is possible to overwrite repository URLs defined elsewhere by defining a repository with the same ID, as long as the file has precedence according to the order defined in the docs.

This is often used to define a different central repository to replace the default one inherited from the Super POM:

<repositories>
    <repository>
      <id>central</id>
      <url>https://example.com</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

In this PR, I've tried to honor that behavior by gathering the IDs along with the URL and deduplicate by ID according to that precedence.

One caveat is that Maven differentiates between repository and pluginRepository. Our code does not, so if central is overwritten in a repository it will also overwrite it in pluginRepository. It seems somewhat unlikely that only one or the other is overwritten, so I think this is probably ok for now.

@jakecoffman jakecoffman requested a review from a team as a code owner October 12, 2022 20:14
@jakecoffman jakecoffman force-pushed the jakecoffman/maven-overwrite-repository-by-id branch from 4955068 to 7b19233 Compare October 12, 2022 20:26
@jakecoffman
Copy link
Copy Markdown
Member Author

😓 it's here now: #5878

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant