From a27855a6471310c6568e8749d8f8b322d5166b25 Mon Sep 17 00:00:00 2001 From: Christos Malliaridis Date: Mon, 16 Dec 2024 21:10:13 +0100 Subject: [PATCH 1/4] Introduce platform module The platform module includes all dependencies from the version catalog as constraints and is added to the root modules as API for transitive inheritance of the constraints. --- gradle/validation/dependencies.gradle | 245 -------------------------- gradle/validation/error-prone.gradle | 1 + platform/build.gradle | 31 ++++ settings.gradle | 1 + solr/api/build.gradle | 1 + solr/core/build.gradle | 1 + solr/server/build.gradle | 1 + 7 files changed, 36 insertions(+), 245 deletions(-) create mode 100644 platform/build.gradle diff --git a/gradle/validation/dependencies.gradle b/gradle/validation/dependencies.gradle index cfb78ee15a2..04c45e8f825 100644 --- a/gradle/validation/dependencies.gradle +++ b/gradle/validation/dependencies.gradle @@ -64,254 +64,9 @@ allprojects { replacedBy("org.hamcrest:hamcrest", "hamcrest-core was renamed to hamcrest") } } - - constraints { handler -> - consolidatedConfigurations.configureEach { Configuration conf -> - // Add BOMs as they resolve many dependency conflicts - handler.add(conf.name, libs.amazon.awssdk.bom, { - because 'version alignment with known BOM for consistency across project' - }) - handler.add(conf.name, libs.google.cloud.bom, { - because 'version alignment with known BOM for consistency across project' - }) - handler.add(conf.name, libs.fasterxml.jackson.bom, { - because 'version alignment with known BOM for consistency across project' - }) - handler.add(conf.name, libs.opentelemetry.bom, { - because 'version alignment with known BOM for consistency across project' - }) - handler.add(conf.name, libs.grpc.bom, { - because 'version alignment with known BOM for consistency across project' - }) - handler.add(conf.name, libs.netty.bom, { - because 'version alignment with known BOM for consistency across project' - }) - - // Add known dependencies that have multiple versions as constraints - // to align versions - handler.add(conf.name, libs.google.guava, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.google.errorprone.annotations, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.commons.exec, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.xerial.snappy.java, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.grpc.context, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.commonscli.commonscli, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.commonscodec.commonscodec, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.commonsio.commonsio, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.junit.junit, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.grpc.core, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.grpc.protobuf, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.jakarta.annotation.api, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.commons.lang3, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.grpc.stub, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.eclipse.jetty.server, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.fasterxml.woodstox.core, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.slf4j.api, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.slf4j.jultoslf4j, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.commons.compress, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.benmanes.caffeine, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.carrotsearch.hppc, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.log4j.api, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.grpc.api, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.slf4j.jcloverslf4j, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.netty.codechttp, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.bc.jose4j, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.lmax.disruptor, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.httpcomponents.httpclient, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.httpcomponents.httpcore, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.httpcomponents.httpmime, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.zookeeper.zookeeper, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.apache.zookeeper.jute, { - because 'version alignment for consistency across project' - }) - handler.add(conf.name, libs.hamcrest.hamcrest, { - because 'version alignment for consistency across project' - }) - - // Add transitive dependencies as constraints to align versions - handler.add(conf.name, libs.checkerframework.qual, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.google.guava)} uses 3.42.0" + - "\n- ${getFullName(libs.benmanes.caffeine)} uses 3.37.0" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 3.44.0" - }) - handler.add(conf.name, libs.ow2.asm, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.apache.lucene.expressions)} uses 7.2" + - "\n- ${getFullName(libs.apache.tika.parsers)} uses 9.3" - }) - handler.add(conf.name, libs.google.protobuf.java, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.google.errorprone.core)} uses 3.19.6" + - "\n- ${getFullName(libs.apache.tika.parsers)} uses 3.21.5" + - "\n- ${getFullName(libs.apache.calcite.avatica.core)} uses 3.21.9" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 3.25.3" + - "\n- ${getFullName(libs.google.cloud.core)} uses 3.25.3" - }) - handler.add(conf.name, libs.google.gson, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.grpc.core)} uses 2.10.1" + - "\n- ${getFullName(libs.apache.tika.parsers)} uses 2.9.1" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 2.11.0 and 2.10.1" + - "\n- ${getFullName(libs.google.protobuf.java)} uses 2.8.9" + - "\n- ${getFullName(libs.google.cloud.core)} uses 2.8.9 and 2.10.1" + - "\n- ${getFullName(libs.google.auth.oauth2http)} uses 2.10.1" - }) - handler.add(conf.name, libs.google.autovalue.annotations, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 1.10.4" + - "\n- ${getFullName(libs.google.cloud.corehttp)} uses 1.10.4" + - "\n- ${getFullName(libs.google.cloud.core)} uses 1.10.4" + - "\n- ${getFullName(libs.google.api.gax)} uses 1.10.4" + - "\n- ${getFullName(libs.google.auth.oauth2http)} uses 1.10.4" + - "\n- ${getFullName(libs.google.cloud.bom)} uses 1.10.4" + - "\n- ${getFullName(libs.google.errorprone.core)} uses 1.9" - }) - handler.add(conf.name, libs.apache.commons.text, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.apache.calcite.core)} uses 1.11.0" + - "\n- ${getFullName(libs.apache.commons.configuration2)} uses 1.12.0" - }) - handler.add(conf.name, libs.grpc.util, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 1.62.2" + - "\n- ${getFullName(libs.grpc.netty)} uses 1.65.1" - }) - handler.add(conf.name, libs.jodatime.jodatime, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.amazon.awssdk.sdkcore)} uses 2.8.1" + - "\n- ${getFullName(libs.apache.tika.parsers)} uses 2.2" - }) - handler.add(conf.name, libs.google.api.grpc.proto, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.grpc.protobuf.asProvider())} uses 2.29.0" + - "\n- ${getFullName(libs.google.api.gax)} uses 2.41.0" + - "\n- ${getFullName(libs.google.api.grpc.proto)} uses 2.41.0" + - "\n- ${getFullName(libs.google.cloud.core)} uses 2.41.0" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 2.41.0" - }) - handler.add(conf.name, libs.netty.handler, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.apache.zookeeper.zookeeper)} uses 4.1.105.Final" + - "\n- ${getFullName(libs.netty.codechttp)} uses 4.1.112.Final" - }) - handler.add(conf.name, libs.grpc.protobuf.lite, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 1.62.2" + - "\n- ${getFullName(libs.grpc.protobuf.asProvider())} uses 1.65.1" - }) - handler.add(conf.name, libs.jaxb.runtime, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.apache.tika.parsers)} uses 2.3.5" + - "\n- ${getFullName(libs.adobe.testing.s3mock.testsupportcommon)} uses 2.3.8" - }) - handler.add(conf.name, libs.perfmark.api, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.grpc.core)} uses 0.26.0" + - "\n- ${getFullName(libs.grpc.netty)} uses 0.26.0" + - "\n- ${getFullName(libs.google.cloud.storage)} uses 0.27.0" - }) - handler.add(conf.name, libs.netty.tcnative.boringssl, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.netty.bom)} uses 2.0.66.Final" + - "\n- ${getFullName(libs.apache.zookeeper.zookeeper)} uses 2.0.61.Final" - }) - handler.add(conf.name, libs.netty.transport.classes.epoll, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.netty.bom)} uses 4.1.114.Final" + - "\n- ${getFullName(libs.apache.zookeeper.zookeeper)} uses 4.1.105.Final" - }) - handler.add(conf.name, libs.netty.transport.native.epoll, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.netty.bom)} uses 4.1.114.Final" + - "\n- ${getFullName(libs.apache.zookeeper.zookeeper)} uses 4.1.105.Final" - }) - handler.add(conf.name, libs.google.j2objc.annotations, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.google.guava)} uses 3.0.0" + - "\n- ${getFullName(libs.google.protobuf.javautils)} uses 2.8" - }) - handler.add(conf.name, libs.apiguardian.api, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.apache.calcite.core)} uses 1.1.2" + - "\n- ${getFullName(libs.junit.junit)} (api) uses 1.1.0" - }) - handler.add(conf.name, libs.hk2.locator, { - because "transitive version alignment for consistency across project" + - "\n- ${getFullName(libs.jersey.inject.hk2)} uses 3.0.6" + - "\n- ${getFullName(libs.hk2.api)} uses 3.1.1" - }) - } - } } } -static def getFullName(Provider dependency) { - def resolvedDep = dependency.get() - return "${resolvedDep.module.group}:${resolvedDep.module.name}" -} - // Configure version catalog cleanups plugin. configure(rootProject) { apply plugin: libs.plugins.littlerobots.versioncatalogupdate.get().pluginId diff --git a/gradle/validation/error-prone.gradle b/gradle/validation/error-prone.gradle index b7242b566c0..f6e418864a5 100644 --- a/gradle/validation/error-prone.gradle +++ b/gradle/validation/error-prone.gradle @@ -48,6 +48,7 @@ allprojects { prj -> errorprone } dependencies { + errorprone platform(project(":platform")) errorprone libs.google.errorprone.core } configurations.annotationProcessor.extendsFrom(configurations.errorprone) diff --git a/platform/build.gradle b/platform/build.gradle new file mode 100644 index 00000000000..b61742241bd --- /dev/null +++ b/platform/build.gradle @@ -0,0 +1,31 @@ +/* + * 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. + */ + +plugins { + id("java-platform") +} + +dependencies { + constraints { + def versionCatalog = rootProject.extensions + .getByType(VersionCatalogsExtension).named("libs") + versionCatalog.libraryAliases.forEach { alias -> + def library = versionCatalog.findLibrary(alias) + api library.get() + } + } +} diff --git a/settings.gradle b/settings.gradle index 99c6540aa7d..250c75e63a6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -35,6 +35,7 @@ rootProject.name = "solr-root" includeBuild("build-tools/missing-doclet") +include ":platform" include "solr:api" include "solr:solrj" include "solr:solrj-zookeeper" diff --git a/solr/api/build.gradle b/solr/api/build.gradle index adad0302602..0b808290726 100644 --- a/solr/api/build.gradle +++ b/solr/api/build.gradle @@ -58,6 +58,7 @@ resolve { } dependencies { + api platform(project(":platform")) runtimeOnly libs.slf4j.api implementation libs.jakarta.ws.rsapi diff --git a/solr/core/build.gradle b/solr/core/build.gradle index f406f842201..42c3ed03889 100644 --- a/solr/core/build.gradle +++ b/solr/core/build.gradle @@ -20,6 +20,7 @@ apply plugin: 'java-library' description = 'Apache Solr Core' dependencies { + api platform(project(":platform")) // Spotbugs Annotations are only needed for old findbugs // annotation usage like in Zookeeper during compilation time. // It is not included in the release so exclude from checks. diff --git a/solr/server/build.gradle b/solr/server/build.gradle index a7055de6539..2939dd9c090 100644 --- a/solr/server/build.gradle +++ b/solr/server/build.gradle @@ -37,6 +37,7 @@ configurations { } dependencies { + serverLib platform(project(":platform")) serverLib(libs.eclipse.jetty.deploy, { exclude group: "org.awaitility", module: "awaitility" }) From 6bce484cceb29ce6dcce252b863d13f84d0408a3 Mon Sep 17 00:00:00 2001 From: Christos Malliaridis Date: Mon, 16 Dec 2024 22:33:42 +0100 Subject: [PATCH 2/4] Cleanup version catalog --- gradle/libs.versions.toml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9f2e4d5d57d..ff529b39b6d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -74,7 +74,6 @@ checkerframework = "3.44.0" codehaus-woodstox = "4.2.2" commons-cli = "1.9.0" commons-codec = "1.17.1" -commons-collections = "3.2.2" commons-io = "2.15.1" cutterslade-analyze = "1.10.0" cybozulabs-langdetect = "1.1-20120112" @@ -101,8 +100,6 @@ google-cloud-nio = "0.127.3" google-cloud-storage = "2.27.0" google-errorprone = "2.31.0" # @keep for version alignment -google-failureaccess = "1.0.2" -# @keep for version alignment google-gson = "2.11.0" google-guava = "33.1.0-jre" # @keep for version alignment @@ -111,7 +108,6 @@ google-j2objc = "3.0.0" google-javaformat = "1.18.1" # @keep for version alignment google-protobuf = "3.25.3" -google-re2j = "1.7" # @keep Gradle version to run the build gradle = "8.10" grpc = "1.65.1" @@ -293,7 +289,6 @@ checkerframework-qual = { module = "org.checkerframework:checker-qual", version. codehaus-woodstox-stax2api = { module = "org.codehaus.woodstox:stax2-api", version.ref = "codehaus-woodstox" } commonscli-commonscli = { module = "commons-cli:commons-cli", version.ref = "commons-cli" } commonscodec-commonscodec = { module = "commons-codec:commons-codec", version.ref = "commons-codec" } -commonscollections-commonscollections = { module = "commons-collections:commons-collections", version.ref = "commons-collections" } commonsio-commonsio = { module = "commons-io:commons-io", version.ref = "commons-io" } cybozulabs-langdetect = { module = "com.cybozu.labs:langdetect", version.ref = "cybozulabs-langdetect" } dropwizard-metrics-core = { module = "io.dropwizard.metrics:metrics-core", version.ref = "dropwizard-metrics" } @@ -361,7 +356,6 @@ google-j2objc-annotations = { module = "com.google.j2objc:j2objc-annotations", v # @keep transitive dependency for version alignment google-protobuf-java = { module = "com.google.protobuf:protobuf-java", version.ref = "google-protobuf" } google-protobuf-javautils = { module = "com.google.protobuf:protobuf-java-util", version.ref = "google-protobuf" } -google-re2j = { module = "com.google.re2j:re2j", version.ref = "google-re2j" } # @keep transitive dependency for version alignment grpc-api = { module = "io.grpc:grpc-api", version.ref = "grpc" } # @keep transitive dependency for version alignment @@ -414,6 +408,7 @@ netty-tcnative-boringssl = { module = "io.netty:netty-tcnative-boringssl-static" netty-tcnative-classes = { module = "io.netty:netty-tcnative-classes", version.ref = "netty-tcnative" } # @keep transitive dependency for version alignment netty-transport-classes-epoll = { module = "io.netty:netty-transport-classes-epoll", version.ref = "netty" } +# @keep transitive dependency for version alignment netty-transport-native-epoll = { module = "io.netty:netty-transport-native-epoll", version.ref = "netty" } nimbusds-josejwt = { module = "com.nimbusds:nimbus-jose-jwt", version.ref = "nimbusds-josejwt" } openjdk-jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "openjdk-jmh" } From 2d195bd10ded483b0d0f612b42bfeb1c40b352a2 Mon Sep 17 00:00:00 2001 From: Christos Malliaridis Date: Mon, 16 Dec 2024 22:34:07 +0100 Subject: [PATCH 3/4] Fix dependency conflicts when errorprone enabled --- gradle/validation/error-prone.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle/validation/error-prone.gradle b/gradle/validation/error-prone.gradle index f6e418864a5..9358d5b4cd1 100644 --- a/gradle/validation/error-prone.gradle +++ b/gradle/validation/error-prone.gradle @@ -56,6 +56,7 @@ allprojects { prj -> prj.apply plugin: libs.plugins.ltgt.errorprone.get().pluginId dependencies { + errorprone platform(project(":platform")) errorprone libs.google.errorprone.core } From 5cdbd202c95b8071140b6174771df51b9d8da703 Mon Sep 17 00:00:00 2001 From: Christos Malliaridis Date: Mon, 16 Dec 2024 22:34:22 +0100 Subject: [PATCH 4/4] Add comment about platform module --- platform/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platform/build.gradle b/platform/build.gradle index b61742241bd..b0a05e07443 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -15,6 +15,9 @@ * limitations under the License. */ +// The platform module allows a centralized dependency management and alignment +// that is inherited by all modules through transitive dependencies (api). + plugins { id("java-platform") }