Apache Solr open-source search software
SOLR-18396: Stop dependency-locking the throwaway "...Copy" configurations (#4794)
Jan Høydahl7669edb60eca
diff --git a/.github/renovate.json b/.github/renovate.jsonindex e21907b54f3..73a766f14d1 100644--- a/.github/renovate.json+++ b/.github/renovate.json@@ -9,11 +9,11 @@"includePaths": ["gradle/libs.versions.toml", "versions.*", "build.gradle", ".github/workflows/*"],"postUpgradeTasks": {"commands": [- "./gradlew resolveAndLockAll collectJarInfos --write-locks",+ "./gradlew resolveAndLockAll --write-locks","./gradlew kotlinUpgradeYarnLock","./gradlew updateLicenses"],- "fileFilters": ["solr/licenses/*.sha1", "solr/**/gradle.lockfile"],+ "fileFilters": ["solr/licenses/*.sha1", "**/gradle.lockfile", "settings-gradle.lockfile"],"executionMode": "branch"},"packageRules": [diff --git a/AGENTS.md b/AGENTS.mdindex c860300686a..ab22fdb9e5e 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -8,7 +8,7 @@ While README.md and CONTRIBUTING.md are mainly written for humans, this file is- Always apply the Apache License to new source files- All versions must be delcared in `gradle/libs.versions.toml`, never build.gradle files- Try first declaring a dependency without a version (the version might already be in a BOM); and if fails to resolve _then_ specify a version-- Always run `gradlew updateLicenses resolveAndLockAll collectJarInfos --write-locks` after adding or changing a dependency. See `dev-docs/gradle-help/dependencies.txt` for more info+- Always run `gradlew updateLicenses resolveAndLockAll --write-locks` after adding or changing a dependency. See `dev-docs/gradle-help/dependencies.txt` for more info## Build and Development Workflowdiff --git a/dev-docs/gradle-help/dependencies.txt b/dev-docs/gradle-help/dependencies.txtindex ce76d51da3e..a20e2595641 100644--- a/dev-docs/gradle-help/dependencies.txt+++ b/dev-docs/gradle-help/dependencies.txt@@ -99,10 +99,7 @@ like when using it with "classpath [dependency]" or for version alignment.The next you want to update the lockfiles file using the following command:-gradlew resolveAndLockAll collectJarInfos --write-locks--The collectJarInfos task is included because it also resolves the dynamic-"...Copy" configurations used by jar validation.+gradlew resolveAndLockAll --write-locksStarting in Solr 10, we also have to update a kotlin-js-store lockfilethat is used by the new Admin UI WebAssembly target. This can be done bydiff --git a/dev-docs/lucene-upgrade.md b/dev-docs/lucene-upgrade.mdindex dd17ef42380..8060a5f3de5 100644--- a/dev-docs/lucene-upgrade.md+++ b/dev-docs/lucene-upgrade.md@@ -6,15 +6,15 @@ https://lucene.apache.org/core/9_4_0/MIGRATE.html## Start-Create a new branch locally e.g. `git checkout -b lucene1040 -t origin/main` for upgrading to Lucene 10.4.0 version.+Create a new branch locally e.g. `git checkout -b lucene1051 -t origin/main` for upgrading to Lucene 10.5.1 version.## Build### `gradle/libs.versions.toml` update```-- apache-lucene:*=10.3.0-+ apache-lucene:*=10.4.0+-apache-lucene = "10.4.0"++apache-lucene = "10.5.1"```### lockfiles update@@ -31,6 +31,10 @@ Create a new branch locally e.g. `git checkout -b lucene1040 -t origin/main` forgit add solr/licenses```+Note that `updateLicenses` compiles Solr, because it enumerates the JARs on the+compile and runtime classpaths. If Lucene made signature changes, fix the code+first (see below) and then come back to this step.+## Code```diff --git a/gradle/solr/packaging.gradle b/gradle/solr/packaging.gradleindex ae3bfcc765d..1984acc5a99 100644--- a/gradle/solr/packaging.gradle+++ b/gradle/solr/packaging.gradle@@ -92,8 +92,7 @@ configure(allprojectsreturn true}}- // The copy does not inherit consistent resolution, re-align so we ship the tested versions- alignWithRuntimeClasspath(externalLibs)+ pinCopyToSource(externalLibs, configurations.runtimeLibs)return externalLibs - configurations.solrPlatformLibs}, {into "lib"@@ -120,6 +119,7 @@ configure(allprojectsdef testRuntimeLibs = configurations.testRuntimeClasspath.copyRecursive {dep ->!(dep instanceof org.gradle.api.artifacts.ProjectDependency)}+ pinCopyToSource(testRuntimeLibs, configurations.testRuntimeClasspath)return testRuntimeLibs - configurations.runtimeLibs})diff --git a/gradle/validation/dependencies.gradle b/gradle/validation/dependencies.gradleindex d0df3444bd9..ec55c5156e3 100644--- a/gradle/validation/dependencies.gradle+++ b/gradle/validation/dependencies.gradle@@ -56,6 +56,15 @@ allprojects {conf.shouldResolveConsistentlyWith(project.configurations.runtimeClasspath)}+ // Helper for the throwaway configurations produced by Configuration.copyRecursive(). Gradle names+ // them "<source>Copy" and lockAllConfigurations() above would otherwise give them lock state of+ // their own, which nothing ever refreshes because they exist only while a task is executing.+ // They still have to resolve to the versions the source configuration was locked to.+ ext.pinCopyToSource = { Configuration copy, Configuration source ->+ copy.resolutionStrategy.deactivateDependencyLocking()+ copy.shouldResolveConsistentlyWith(source)+ }+dependencies {modules {module("org.hamcrest:hamcrest-core") {diff --git a/gradle/validation/jar-checks.gradle b/gradle/validation/jar-checks.gradleindex 24d294ef93e..0f137c68734 100644--- a/gradle/validation/jar-checks.gradle+++ b/gradle/validation/jar-checks.gradle@@ -142,8 +142,10 @@ subprojects {return validationConf.extendsFrom.collect {conf ->if (excludeRules && excludeRules.size() > 0) {- conf = conf.copyRecursive()+ def source = conf+ conf = source.copyRecursive()conf.canBeResolved = true+ pinCopyToSource(conf, source)excludeRuleMaps.forEach {conf.exclude(it)}}conf