Skip to content

build: centralize maven repo declarations - #4677

Merged
dsmiley merged 6 commits into
apache:mainfrom
dsmiley:buildCentralizeRepoDeclaration
Aug 1, 2026
Merged

build: centralize maven repo declarations#4677
dsmiley merged 6 commits into
apache:mainfrom
dsmiley:buildCentralizeRepoDeclaration

Conversation

@dsmiley

@dsmiley dsmiley commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Centralize repository declarations (single mirror choke-point)

Motivation

Repository declarations (mavenCentral(), gradlePluginPortal()) were scattered
across the build in every distinct Gradle repository scope: plugin resolution,
project dependencies, the buildscript classpath of several convention scripts, and
the two included builds. There was no single place for an enterprise to redirect
resolution to an internal mirror (Artifactory/Nexus).

What this does

Introduces one shared file, build-tools/build-infra/declare-repositories.gradle,
as the single source of repository declarations, and applies it into every
consumption scope via apply from: ..., to: <handler>:

  • settings.gradle -> pluginManagement (plugin resolution)
  • gradle/globals.gradle -> allprojects (project dependencies)
  • solr/ui/build.gradle.kts (keeps its module-specific google(), routes the rest)
  • the buildscript {} blocks in git-status, rat-sources, jar-checks,
    randomization, markdown, and solr/docker (buildscript classpath)
  • build-tools/build-infra and build-tools/missing-doclet (included builds)

Placing the file under build-tools/build-infra/ lets the classloader-isolated
included builds reach it by relative path. This follows the same pattern Lucene
uses upstream.

Enterprise mirror

Set one of the following and the entire build (including the included builds, which
inherit JVM system properties / environment) resolves exclusively from the mirror,
excluding public repositories:

  • -Dsolr.maven.repo.url=https://.../maven (or systemProp.solr.maven.repo.url=...
    in gradle.properties)
  • SOLR_MAVEN_REPO_URL=https://.../maven environment variable

With neither set, behavior is unchanged (mavenCentral() + gradlePluginPortal()).

Notes

  • Removed a dead commented-out LucenePrerelease repository template in
    gradle/globals.gradle (still in git history); it didn't belong in a file shared
    with pluginManagement.
  • Intentionally left alone: publishing targets in gradle/maven/*.gradle and the
    dev-only mavenLocal() in gradle/lucene-dev/* (not consumption repos).

Verification

  • gradlew help (all scopes), :build-infra:help, and :solr:ui:help
    (-PdisableUiModule=false) all configure cleanly.
  • Setting a bogus mirror via both the system property and the env var redirects all
    scopes to it exclusively (plugin resolution fails against the bogus URL only),
    confirming the override works and public repos are dropped.
  • Dependency locking still validates for both the buildscript classpath and project
    configurations; no lockfiles changed (mavenCentral remains first, so resolution is
    unchanged when no mirror is set).

🤖 Generated with Claude Code

repositories {
if (mirrorUrl) {
maven {
name = 'enterpriseMirror'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does enterpriseMirror mean something or does it just need a string? If the latter then IMO "enterprise" has a certain commerce/profit-making connotation which is probably correct in most cases but in the off chance it is not (non-profit/government) maybe we dont have to be so opinionated on this being an "enterprise" mirror. But enterprise is an overloaded term in java so thats a really small nit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's any name. I'll see if I can remove it. I think of "enterprise" as your business, no matter it's nature.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can be removed but seems a best practice / helpful. I'll leave it commented and put "yourEnterpriseMirror"

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Jul 30, 2026
@dsmiley

dsmiley commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Will merge this tomorrow.

@github-actions github-actions Bot removed the documentation Improvements or additions to documentation label Jul 30, 2026
@dsmiley
dsmiley merged commit 54758e8 into apache:main Aug 1, 2026
5 checks passed
@dsmiley
dsmiley deleted the buildCentralizeRepoDeclaration branch August 1, 2026 16:45
@dsmiley

dsmiley commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

I validated this at work -- a build that occurred in a docker container. Disclaimer: did so with several modules disabled like the UI and jsClient. Thus I didn't need NodeJS. Some more adjustments might be needed to accommodate that.

@dsmiley dsmiley added this to the 9.x milestone Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants