Skip to content

Commit ebb2746

Browse files
committed
fix
1 parent dafb251 commit ebb2746

2 files changed

Lines changed: 38 additions & 32 deletions

File tree

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

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

instrumentation/gwt-2.0/javaagent/build.gradle.kts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,19 @@ sourceSets {
2727
}
2828
}
2929

30-
// GWT moved from `com.google.gwt` to `org.gwtproject` in 2.10.0. In latest-deps mode,
31-
// rewrite the compileOnly `com.google.gwt:gwt-{user,dev}` coordinates to the new group so
32-
// the agent compiles against the modern artifacts. `gwt-servlet` is declared directly with
33-
// its post-2.10 coordinates in the dependencies block below, so it doesn't need substitution.
34-
if (otelProps.testLatestDeps) {
35-
configurations.configureEach {
36-
resolutionStrategy.dependencySubstitution {
37-
listOf("gwt-user", "gwt-dev").forEach { artifact ->
38-
substitute(module("com.google.gwt:$artifact"))
39-
.using(module("org.gwtproject:$artifact:latest.release"))
40-
}
41-
}
42-
}
43-
}
44-
4530
dependencies {
31+
// GWT moved from `com.google.gwt` to `org.gwtproject` in 2.10.0
4632
if (otelProps.testLatestDeps) {
4733
library("org.gwtproject:gwt-servlet:latest.release")
34+
library("org.gwtproject:gwt-user:latest.release")
35+
library("org.gwtproject:gwt-dev:latest.release")
4836
} else {
4937
library("com.google.gwt:gwt-servlet:2.0.0")
38+
// these are needed for compileGwt task
39+
compileOnly("com.google.gwt:gwt-user:2.0.0")
40+
compileOnly("com.google.gwt:gwt-dev:2.0.0")
5041
}
5142

52-
// these are needed for compileGwt task
53-
compileOnly("com.google.gwt:gwt-user:2.0.0")
54-
compileOnly("com.google.gwt:gwt-dev:2.0.0")
55-
5643
testInstrumentation(project(":instrumentation:servlet:servlet-3.0:javaagent"))
5744
testInstrumentation(project(":instrumentation:jetty:jetty-8.0:javaagent"))
5845

0 commit comments

Comments
 (0)