This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit aca43a1f16f71c85b4a04491de9925fe5984d8d0
Author: David Smiley <[email protected]>
AuthorDate: Sat Aug 1 12:45:50 2026 -0400

    build: centralize maven repo declarations (#4677)
    
    (cherry picked from commit 54758e81b4012796c03bca0b14d403e1d10204ca)
---
 buildSrc/build.gradle                              |  4 +--
 buildSrc/declare-repositories.gradle               | 42 ++++++++++++++++++++++
 .../PR#4677-buildCentralizeRepoDeclaration.yml     |  8 +++++
 dev-tools/solr-missing-doclet/build.gradle         |  2 ++
 dev-tools/solr-missing-doclet/settings.gradle      |  4 +++
 gradle/documentation/markdown.gradle               | 26 +++++++-------
 gradle/globals.gradle                              | 12 +------
 gradle/testing/randomization.gradle                |  6 ++--
 gradle/validation/git-status.gradle                | 15 ++++----
 gradle/validation/jar-checks.gradle                |  4 +--
 gradle/validation/validate-source-patterns.gradle  |  4 +--
 settings.gradle                                    |  5 +--
 solr/docker/build.gradle                           |  5 ++-
 13 files changed, 84 insertions(+), 53 deletions(-)

diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 91f88741322..7d4544a0b28 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -15,9 +15,7 @@
  * limitations under the License.
  */
 
-repositories {
-  mavenCentral()
-}
+apply from: file("declare-repositories.gradle")
 
 ext {
   // Minimum Java version required to compile buildSrc.
diff --git a/buildSrc/declare-repositories.gradle 
b/buildSrc/declare-repositories.gradle
new file mode 100644
index 00000000000..111ff365b09
--- /dev/null
+++ b/buildSrc/declare-repositories.gradle
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Central repository declarations for every consumption scope: plugin 
resolution
+// (pluginManagement), project dependencies, buildscript classpath, and the
+// build-infra / missing-doclet included builds. Applied via
+// `apply from: <this>, to: <handler>` onto whichever object owns the 
repositories.
+//
+// Your enterprise mirror: set the `solr.maven.repo.url` system property (via
+// -Dsolr.maven.repo.url=..., or systemProp.solr.maven.repo.url=... in 
gradle.properties) or
+// the equivalent SOLR_MAVEN_REPO_URL environment variable to route every 
scope through a
+// single internal mirror (e.g. Artifactory/Nexus) instead of public 
repositories. System
+// properties and environment variables are inherited by the included builds, 
so one setting
+// covers the entire build.
+
+def mirrorUrl = System.getProperty('solr.maven.repo.url') ?: 
System.getenv('SOLR_MAVEN_REPO_URL')
+
+repositories {
+  if (mirrorUrl) {
+    maven {
+      // name = 'yourEnterpriseMirror'
+      url = mirrorUrl
+    }
+  } else {
+    mavenCentral()
+    gradlePluginPortal()
+  }
+}
diff --git a/changelog/unreleased/PR#4677-buildCentralizeRepoDeclaration.yml 
b/changelog/unreleased/PR#4677-buildCentralizeRepoDeclaration.yml
new file mode 100644
index 00000000000..b40fb37d0f7
--- /dev/null
+++ b/changelog/unreleased/PR#4677-buildCentralizeRepoDeclaration.yml
@@ -0,0 +1,8 @@
+title: >
+  Centralize Maven repository declarations for the build.  Can customize with 
SOLR_MAVEN_REPO_URL.
+type: other
+authors:
+  - name: David Smiley
+links:
+  - name: PR#4677
+    url: https://github.com/apache/solr/pull/4677
diff --git a/dev-tools/solr-missing-doclet/build.gradle 
b/dev-tools/solr-missing-doclet/build.gradle
index e85f0a037e4..a158dc61795 100644
--- a/dev-tools/solr-missing-doclet/build.gradle
+++ b/dev-tools/solr-missing-doclet/build.gradle
@@ -19,6 +19,8 @@ plugins {
   id 'java-library'
 }
 
+apply from: file("../../buildSrc/declare-repositories.gradle")
+
 version = "1.0.0-SNAPSHOT"
 group = "org.apache.solr.tools"
 description = 'Doclet-based javadoc validation'
diff --git a/dev-tools/solr-missing-doclet/settings.gradle 
b/dev-tools/solr-missing-doclet/settings.gradle
index 73d696331bc..56ac4eb3097 100644
--- a/dev-tools/solr-missing-doclet/settings.gradle
+++ b/dev-tools/solr-missing-doclet/settings.gradle
@@ -15,4 +15,8 @@
  * limitations under the License.
  */
 
+pluginManagement {
+  apply from: file("../../buildSrc/declare-repositories.gradle"), to: delegate
+}
+
 rootProject.name = "missing-doclet"
diff --git a/gradle/documentation/markdown.gradle 
b/gradle/documentation/markdown.gradle
index 29d23d87c75..a76d026ca86 100644
--- a/gradle/documentation/markdown.gradle
+++ b/gradle/documentation/markdown.gradle
@@ -15,22 +15,20 @@
  * limitations under the License.
  */
 
-import com.vladsch.flexmark.ast.Heading;
-import com.vladsch.flexmark.ext.abbreviation.AbbreviationExtension;
-import com.vladsch.flexmark.ext.attributes.AttributesExtension;
-import com.vladsch.flexmark.ext.autolink.AutolinkExtension;
-import com.vladsch.flexmark.html.HtmlRenderer;
-import com.vladsch.flexmark.parser.Parser;
-import com.vladsch.flexmark.parser.ParserEmulationProfile;
-import com.vladsch.flexmark.util.ast.Document;
-import com.vladsch.flexmark.util.data.MutableDataSet;
-import com.vladsch.flexmark.util.sequence.Escaping;
-import groovy.text.SimpleTemplateEngine;
+import com.vladsch.flexmark.ast.Heading
+import com.vladsch.flexmark.ext.abbreviation.AbbreviationExtension
+import com.vladsch.flexmark.ext.attributes.AttributesExtension
+import com.vladsch.flexmark.ext.autolink.AutolinkExtension
+import com.vladsch.flexmark.html.HtmlRenderer
+import com.vladsch.flexmark.parser.Parser
+import com.vladsch.flexmark.parser.ParserEmulationProfile
+import com.vladsch.flexmark.util.ast.Document
+import com.vladsch.flexmark.util.data.MutableDataSet
+import com.vladsch.flexmark.util.sequence.Escaping
+import groovy.text.SimpleTemplateEngine
 
 buildscript {
-  repositories {
-    mavenCentral()
-  }
+  apply from: rootProject.file('buildSrc/declare-repositories.gradle'), to: 
delegate
 
   dependencies {
     classpath "com.vladsch.flexmark:flexmark:${scriptDepVersions['flexmark']}"
diff --git a/gradle/globals.gradle b/gradle/globals.gradle
index aec37217091..31eb1d94f4b 100644
--- a/gradle/globals.gradle
+++ b/gradle/globals.gradle
@@ -20,18 +20,8 @@ allprojects {
 
   group "org.apache"
 
-  // def lucenePrereleaseBuild = '9'
-
   // Repositories to fetch dependencies from.
-  repositories {
-    mavenCentral()
-    /* Reenable this if we need it again in future
-    maven {
-      name "LucenePrerelease${lucenePrereleaseBuild}"
-      url 
"https://nightlies.apache.org/solr/lucene-prereleases/${lucenePrereleaseBuild}/";
-    }
-    */
-  }
+  apply from: rootProject.file('buildSrc/declare-repositories.gradle'), to: 
delegate
 
   // Artifacts will have names after full gradle project path
   // so :solr:core will have solr-core.jar, etc.
diff --git a/gradle/testing/randomization.gradle 
b/gradle/testing/randomization.gradle
index 4bb30c48ed7..717c82126c1 100644
--- a/gradle/testing/randomization.gradle
+++ b/gradle/testing/randomization.gradle
@@ -19,15 +19,13 @@
 // Configure test randomization seeds and derived test properties.
 //
 
-import java.nio.file.*
 import com.carrotsearch.randomizedtesting.SeedUtils
 import com.carrotsearch.randomizedtesting.generators.RandomPicks
+import java.nio.file.*
 import org.apache.tools.ant.types.Commandline
 
 buildscript {
-  repositories {
-    mavenCentral()
-  }
+  apply from: rootProject.file('buildSrc/declare-repositories.gradle'), to: 
delegate
 
   dependencies {
     classpath 
'com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.9'
diff --git a/gradle/validation/git-status.gradle 
b/gradle/validation/git-status.gradle
index b34cf831ef7..19dae496cdf 100644
--- a/gradle/validation/git-status.gradle
+++ b/gradle/validation/git-status.gradle
@@ -17,20 +17,19 @@
 
 // This verifies local git repository's status.
 
-import org.eclipse.jgit.api.*
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder
-import org.eclipse.jgit.errors.*
-
 import java.nio.file.FileVisitResult
 import java.nio.file.Files
-import java.nio.file.SimpleFileVisitor
 import java.nio.file.Path
+import java.nio.file.SimpleFileVisitor
 import java.nio.file.attribute.BasicFileAttributes
+import org.eclipse.jgit.api.Git
+import org.eclipse.jgit.errors.NoWorkTreeException
+import org.eclipse.jgit.errors.NotSupportedException
+import org.eclipse.jgit.errors.RepositoryNotFoundException
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder
 
 buildscript {
-  repositories {
-    mavenCentral()
-  }
+  apply from: rootProject.file('buildSrc/declare-repositories.gradle'), to: 
delegate
 
   dependencies {
     classpath "org.eclipse.jgit:org.eclipse.jgit:${scriptDepVersions['jgit']}"
diff --git a/gradle/validation/jar-checks.gradle 
b/gradle/validation/jar-checks.gradle
index 1060330b6ab..01f5352e31b 100644
--- a/gradle/validation/jar-checks.gradle
+++ b/gradle/validation/jar-checks.gradle
@@ -33,9 +33,7 @@ def failOnError = true
 
 // We're using commons-codec for computing checksums.
 buildscript {
-  repositories {
-    mavenCentral()
-  }
+  apply from: rootProject.file('buildSrc/declare-repositories.gradle'), to: 
delegate
 
   dependencies {
     classpath 
"commons-codec:commons-codec:${scriptDepVersions['commons-codec']}"
diff --git a/gradle/validation/validate-source-patterns.gradle 
b/gradle/validation/validate-source-patterns.gradle
index 373bacbb8c9..bb254d37605 100644
--- a/gradle/validation/validate-source-patterns.gradle
+++ b/gradle/validation/validate-source-patterns.gradle
@@ -24,9 +24,7 @@ import 
org.gradle.internal.logging.progress.ProgressLoggerFactory
 import org.gradle.internal.logging.progress.ProgressLogger
 
 buildscript {
-  repositories {
-    mavenCentral()
-  }
+  apply from: rootProject.file('buildSrc/declare-repositories.gradle'), to: 
delegate
 
   dependencies {
     classpath "org.apache.rat:apache-rat:${scriptDepVersions['apache-rat']}"
diff --git a/settings.gradle b/settings.gradle
index 293b9d450bd..4aa4aafa52f 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -16,10 +16,7 @@
  */
 
 pluginManagement {
-    repositories {
-        mavenCentral()
-        gradlePluginPortal()
-    }
+    apply from: file("buildSrc/declare-repositories.gradle"), to: delegate
 }
 
 plugins {
diff --git a/solr/docker/build.gradle b/solr/docker/build.gradle
index 6d7d287bace..8a5bfc1843e 100644
--- a/solr/docker/build.gradle
+++ b/solr/docker/build.gradle
@@ -136,9 +136,8 @@ dependencies {
 
 // We're using commons-codec for computing checksums.
 buildscript {
-  repositories {
-    mavenCentral()
-  }
+  apply from: rootProject.file('buildSrc/declare-repositories.gradle'), to: 
delegate
+
   dependencies {
     classpath 
"commons-codec:commons-codec:${scriptDepVersions['commons-codec']}"
   }

Reply via email to