Skip to content

Commit 854e929

Browse files
committed
Restrict latestDepTestLibrary overrides to main test/latestDepTest configurations
The previous PR broadened the resolutionStrategy filter to all 'test*' configurations (case-insensitive contains) so that custom JvmTestSuite source sets get pinning. However this also caused latestDepTestLibrary overrides (intended only for the main test/latestDepTest suites) to be applied to those custom suites, breaking modules that declare a JvmTestSuite with explicit older versions (e.g. play-mvc-2.4 play24Test, kubernetes-client-7.0 version20Test). Split the filter: keep overrides scoped to test/latestDepTest, broaden only the pinning logic.
1 parent a52a81a commit 854e929

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

conventions/src/main/kotlin/io.opentelemetry.instrumentation.base.gradle.kts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,30 @@ configurations {
173173
if (otelProps.testLatestDeps) {
174174
// Only apply to test-related configurations, not build tool configurations like Zinc
175175
// (the Scala compiler). Overriding scala-library in Zinc's configuration breaks compilation.
176-
// We match any configuration whose name contains "test" (case-insensitive) so that custom
177-
// JvmTestSuite source sets (e.g. `version5TestRuntimeClasspath`) are also covered.
178176
configureEach {
179-
if (isCanBeResolved && name.contains("test", ignoreCase = true)) {
180-
resolutionStrategy.eachDependency {
177+
if (!isCanBeResolved) return@configureEach
178+
// latestDepTestLibrary overrides only apply to the main test/latestDepTest configurations.
179+
// Custom JvmTestSuite source sets (e.g. `version20TestRuntimeClasspath`,
180+
// `play24TestRuntimeClasspath`) declare their own explicit versions and must not be
181+
// affected by overrides intended for the main test suite.
182+
val applyOverrides = name.startsWith("test") || name.startsWith("latestDepTest")
183+
// Pinning of `latest.release`/`+` versions is applied broadly (case-insensitive "test"
184+
// match) so that custom JvmTestSuite source sets are also reproducible.
185+
val applyPinning = pinLatestDeps && name.contains("test", ignoreCase = true)
186+
if (!applyOverrides && !applyPinning) return@configureEach
187+
resolutionStrategy.eachDependency {
188+
if (applyOverrides) {
181189
// latestDepTestLibrary overrides take priority over pinned versions
182190
val override = latestDepTestLibraryOverrides["${requested.group}:${requested.name}"]
183191
if (override != null) {
184192
useVersion(override)
185193
return@eachDependency
186194
}
187-
if (pinLatestDeps) {
188-
val pinnedVersion = lookupPinnedVersion(requested.group, requested.name, requested.version)
189-
if (pinnedVersion != null) {
190-
useVersion(pinnedVersion)
191-
}
195+
}
196+
if (applyPinning) {
197+
val pinnedVersion = lookupPinnedVersion(requested.group, requested.name, requested.version)
198+
if (pinnedVersion != null) {
199+
useVersion(pinnedVersion)
192200
}
193201
}
194202
}

0 commit comments

Comments
 (0)