@@ -162,23 +162,42 @@ configurations {
162162 // "latest.release" or "+" versions (e.g. transitive deps) gets pinned to a concrete
163163 // version from the JSON file.
164164 if (otelProps.testLatestDeps) {
165- // Apply latestDepTestLibrary overrides and pinned versions to every resolvable
166- // configuration. Both maps only contain entries the module author explicitly opted into
167- // (`latestDepTestLibrary(...)` declarations and `library`/`testLibrary` artifacts pinned
168- // in latest-dep-versions.json), and the lookups are no-ops for unrelated artifacts and
169- // for concrete versions — so broad application costs nothing but keeps every dynamic
170- // version in the build reproducible, including custom JvmTestSuite source sets and
171- // `compileClasspath` entries rewritten via dependencySubstitution (e.g. gwt-2.0).
165+ // Pinning and overrides must NOT leak into build-tool configurations like Zinc (the
166+ // Scala compiler), where forcing e.g. scala-library to a JSON-pinned version breaks
167+ // compilation. They also must not affect e.g. japicmp's `tempConfig`, which resolves
168+ // `opentelemetry-instrumentation-bom:latest.release` directly against Maven Central.
169+ // Use an allow-list of configuration names rather than a deny-list so new build-tool
170+ // configurations stay safe by default.
172171 configureEach {
173172 if (! isCanBeResolved) return @configureEach
173+ // `latestDepTestLibrary` overrides apply ONLY to test-classpath configurations.
174+ // They must NOT touch `compileClasspath`, because the whole point of `library(old)` +
175+ // `latestDepTestLibrary(newRange)` is to keep the agent compiling against the old API
176+ // while testing against the new one. Forcing the override onto compileClasspath would
177+ // upgrade the compileOnly `library(...)` version and break compilation (e.g.
178+ // scala-fork-join-2.8 compiles against scala 2.8 APIs, vertx-sql-client-4.0 against
179+ // generic vertx 4.0 APIs, elasticsearch-transport-5.0 against generic ES 5.0 APIs).
180+ val applyOverrides = name.contains(" test" , ignoreCase = true )
181+ // Pinning of `latest.release`/`+` versions is applied across test-related
182+ // configurations and the main `compileClasspath`. compileClasspath is included so
183+ // that modules whose `library(...)` declarations resolve `latest.release` in latest
184+ // mode (e.g. gwt-2.0, which uses the post-2.10 `org.gwtproject` group only in latest
185+ // mode) get pinned versions on the agent's compile classpath. Pinning is safe on
186+ // compileClasspath because `lookupPinnedVersion` is a no-op for the concrete versions
187+ // declared via `library(...)`; only dynamic versions (latest.release / +) are affected.
188+ val applyPinning = pinLatestDeps &&
189+ (name.contains(" test" , ignoreCase = true ) || name == " compileClasspath" )
190+ if (! applyOverrides && ! applyPinning) return @configureEach
174191 resolutionStrategy.eachDependency {
175- // latestDepTestLibrary overrides take priority over pinned versions
176- val override = latestDepTestLibraryOverrides[" ${requested.group} :${requested.name} " ]
177- if (override != null ) {
178- useVersion(override )
179- return @eachDependency
192+ if (applyOverrides) {
193+ // latestDepTestLibrary overrides take priority over pinned versions
194+ val override = latestDepTestLibraryOverrides[" ${requested.group} :${requested.name} " ]
195+ if (override != null ) {
196+ useVersion(override )
197+ return @eachDependency
198+ }
180199 }
181- if (pinLatestDeps ) {
200+ if (applyPinning ) {
182201 val pinnedVersion = lookupPinnedVersion(requested.group, requested.name, requested.version)
183202 if (pinnedVersion != null ) {
184203 useVersion(pinnedVersion)
0 commit comments