Skip to content

Commit b6968e5

Browse files
traskCopilotlaurit
authored
Clean up latest dependency override comments (#18968)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Lauri Tulmin <ltulmin@splunk.com>
1 parent 9988fc8 commit b6968e5

27 files changed

Lines changed: 98 additions & 55 deletions

File tree

.github/scripts/check-latest-dep-test-overrides.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash -e
22

33
# all missing version coverage should be documented in supported-libraries.md
4+
# (otherwise add one of the required annotations below)
45

56
if grep -r --include build.gradle.kts latestDepTestLibrary instrumentation \
67
| grep -v -e :+\" -e :latest.release\" \
@@ -15,7 +16,7 @@ if grep -r --include build.gradle.kts latestDepTestLibrary instrumentation \
1516
echo
1617
echo "Found an undocumented latestDepTestLibrary (see above)."
1718
echo
18-
echo "See .gith/scripts/check-latest-dep-test-overrides.sh in this repository"
19+
echo "See .github/scripts/check-latest-dep-test-overrides.sh in this repository"
1920
echo "and add one of the required comments."
2021
exit 1
2122
fi

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

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.opentelemetry.instrumentation.gradle.OtelPropsExtension
44
import io.opentelemetry.javaagent.muzzle.AcceptableVersions
5+
import org.eclipse.aether.util.version.GenericVersionScheme
56

67
plugins {
78
`java-library`
@@ -17,8 +18,9 @@ val otelProps = the<OtelPropsExtension>()
1718
* - library: A dependency on the instrumented library. Results in the dependency being added to
1819
* compileOnly and testImplementation. If the build is run with -PtestLatestDeps=true, the
1920
* version when added to testImplementation will be overridden by `+`, the latest version
20-
* possible. For simple libraries without different behavior between versions, it is possible
21-
* to have a single dependency on library only.
21+
* possible, but never below the declared library version. For simple libraries without
22+
* different behavior between versions, it is possible to have a single dependency on library
23+
* only.
2224
*
2325
* - testLibrary: A dependency on a library for testing. This will usually be used to either
2426
* a) use a different version of the library for compilation and testing and b) to add a helper
@@ -68,6 +70,30 @@ fun lookupPinnedVersion(group: String?, name: String, version: String?): String?
6870
)
6971
}
7072

73+
val versionScheme = GenericVersionScheme()
74+
75+
// Pinned latest-dep versions resolve "latest" to the latest stable release, which can be lower
76+
// than a module's declared test baseline when the newer supported line only has pre-releases.
77+
// This currently affects ActiveJ: the instrumentation supports 6.0-rc2 and later, but there
78+
// are no stable 6.x releases yet, so latest stable is still 5.5.
79+
fun pinnedVersionAtLeastDeclared(pinnedVersion: String?, declaredVersion: String?): String? {
80+
if (pinnedVersion == null || declaredVersion == null || declaredVersion == "latest.release" ||
81+
declaredVersion.contains("+") ||
82+
declaredVersion.startsWith("[") ||
83+
declaredVersion.startsWith("(")) {
84+
return pinnedVersion
85+
}
86+
return try {
87+
if (versionScheme.parseVersion(declaredVersion) > versionScheme.parseVersion(pinnedVersion)) {
88+
declaredVersion
89+
} else {
90+
pinnedVersion
91+
}
92+
} catch (e: RuntimeException) {
93+
pinnedVersion
94+
}
95+
}
96+
7197
@CacheableRule
7298
abstract class TestLatestDepsRule : ComponentMetadataRule {
7399
override fun execute(context: ComponentMetadataContext) {
@@ -105,8 +131,9 @@ configurations {
105131
if (otelProps.testLatestDeps) {
106132
val extDep = this as ExternalDependency
107133
val pinnedVersion = lookupPinnedVersion(extDep.group, extDep.name, "latest.release")
134+
val resolvedVersion = pinnedVersionAtLeastDeclared(pinnedVersion, extDep.version)
108135
(dep as ExternalDependency).version {
109-
require(pinnedVersion ?: "latest.release")
136+
require(resolvedVersion ?: "latest.release")
110137
}
111138
}
112139
testImplementation.dependencies.add(dep)

docs/supported-libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ These are the supported libraries and frameworks:
154154
| [Spring Pulsar](https://spring.io/projects/spring-pulsar) | 1.0+ | | [Messaging Spans] |
155155
| [Spring RabbitMQ](https://spring.io/projects/spring-amqp) | 1.0+ | N/A | [Messaging Spans] |
156156
| [Spring RestTemplate](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/package-summary.html) | 3.1+ | [opentelemetry-spring-web-3.1](../instrumentation/spring/spring-web/spring-web-3.1/library) | [HTTP Client Spans], [HTTP Client Metrics] |
157-
| [Spring RMI](https://docs.spring.io/spring-framework/docs/4.0.x/javadoc-api/org/springframework/remoting/rmi/package-summary.html) | 4.0+ | N/A | [RPC Client Spans], [RPC Server Spans] |
157+
| [Spring RMI](https://docs.spring.io/spring-framework/docs/4.0.x/javadoc-api/org/springframework/remoting/rmi/package-summary.html) | 4.0 - 5.x | N/A | [RPC Client Spans], [RPC Server Spans] |
158158
| [Spring Scheduling](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/package-summary.html) | 3.1+ | N/A | none |
159159
| [Spring Web MVC](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/mvc/package-summary.html) | 3.1+ | [opentelemetry-spring-webmvc-5.3](../instrumentation/spring/spring-webmvc/spring-webmvc-5.3/library),<br>[opentelemetry-spring-webmvc-6.0](../instrumentation/spring/spring-webmvc/spring-webmvc-6.0/library) | [HTTP Server Spans], [HTTP Server Metrics], Provides `http.route` [2], Controller Spans [3] |
160160
| [Spring Web Services](https://spring.io/projects/spring-ws) | 2.0+ (not including 4.0+ yet) | N/A | none |

instrumentation/activej-http-6.0/javaagent/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ muzzle {
1313

1414
dependencies {
1515
library("io.activej:activej-http:6.0-rc2")
16-
latestDepTestLibrary("io.activej:activej-http:6.+") // documented limitation, can be removed when there is a non rc version in 6.x series
1716
}
1817

1918
otelJava {

instrumentation/apache-httpclient/apache-httpclient-4.3/library/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ dependencies {
88
library("org.apache.httpcomponents:httpclient:4.3")
99

1010
testImplementation(project(":instrumentation:apache-httpclient:apache-httpclient-4.3:testing"))
11-
12-
latestDepTestLibrary("org.apache.httpcomponents:httpclient:4.+") // see apache-httpclient-5.0 module
1311
}
1412

1513
tasks {

instrumentation/apache-shenyu-2.4/javaagent/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ dependencies {
2626
exclude("org.codehaus.groovy", "groovy")
2727
}
2828

29-
// the latest version of apache shenyu uses spring-boot 3.3
3029
latestDepTestLibrary("org.springframework.boot:spring-boot-starter-test:3.3.+") // related dependency
3130

3231
testInstrumentation(project(":instrumentation:netty:netty-4.1:javaagent"))

instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ dependencies {
5454

5555
testLibrary("org.springframework.data:spring-data-elasticsearch:3.0.0.RELEASE")
5656

57-
latestDepTestLibrary("org.elasticsearch.plugin:transport-netty3-client:5.+") // see elasticsearch-transport-6.0 module
5857
latestDepTestLibrary("org.elasticsearch.client:transport:5.+") // see elasticsearch-transport-6.0 module
5958
latestDepTestLibrary("org.springframework.data:spring-data-elasticsearch:3.0.+") // see elasticsearch-transport-6.0 module
6059
}

instrumentation/grizzly-2.3/javaagent/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ dependencies {
2121

2222
// testLibrary("org.glassfish.grizzly:grizzly-http-server:2.3")
2323
testImplementation("org.glassfish.grizzly:grizzly-http-server:2.3")
24-
25-
// 5.0.0 depends on org.glassfish.grizzly:grizzly-bom:5.0.0-SNAPSHOT which is not available
26-
latestDepTestLibrary("org.glassfish.grizzly:grizzly-http:4.+") // documented limitation
27-
latestDepTestLibrary("org.glassfish.grizzly:grizzly-http-server:4.+") // documented limitation
2824
}
2925

3026
tasks {

instrumentation/hibernate/hibernate-procedure-call-4.3/javaagent/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ dependencies {
2828
testImplementation("javax.xml.bind:jaxb-api:2.3.1")
2929
testImplementation("org.glassfish.jaxb:jaxb-runtime:2.3.3")
3030

31-
latestDepTestLibrary("org.hibernate:hibernate-core:5.+") // documented limitation
32-
latestDepTestLibrary("org.hibernate:hibernate-entitymanager:5.+") // documented limitation
31+
latestDepTestLibrary("org.hibernate:hibernate-core:5.+") // see hibernate-6.0 module
32+
latestDepTestLibrary("org.hibernate:hibernate-entitymanager:5.+") // see hibernate-6.0 module
3333
}
3434

3535
tasks {

instrumentation/jsf/jsf-mojarra-3.0/javaagent/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies {
3232
testInstrumentation(project(":instrumentation:jsf:jsf-mojarra-1.2:javaagent"))
3333

3434
// JSF 4+ requires CDI instead of BeanManager, the test should be upgraded first
35-
latestDepTestLibrary("jakarta.el:jakarta.el-api:4.+") // documented limitation
35+
latestDepTestLibrary("jakarta.el:jakarta.el-api:4.+") // related dependency
3636
latestDepTestLibrary("jakarta.faces:jakarta.faces-api:3.+") // documented limitation
3737
latestDepTestLibrary("org.glassfish:jakarta.faces:3.+") // documented limitation
3838
}

0 commit comments

Comments
 (0)