Skip to content

Commit 037c3ea

Browse files
cwperksreta
andauthored
[Backport 2.x] Switch from buildSrc/version.properties to Gradle version catalog (gradle/libs.versions.toml) to enable dependabot to perform automated upgrades on common libs (#16284) (#16508)
* Switch from `buildSrc/version.properties` to Gradle version catalog (`gradle/libs.versions.toml`) to enable dependabot to perform automated upgrades on common libs (#16284) * WIP on lib toml Signed-off-by: Craig Perkins <[email protected]> * SpotlessApply Signed-off-by: Craig Perkins <[email protected]> * Remove unnecessary lines Signed-off-by: Craig Perkins <[email protected]> * Specify time when dependabot runs Signed-off-by: Craig Perkins <[email protected]> * Refer to version from libs.versions.toml Signed-off-by: Craig Perkins <[email protected]> * Use version Signed-off-by: Craig Perkins <[email protected]> * Specify version catalog Signed-off-by: Craig Perkins <[email protected]> * Call .get() Signed-off-by: Craig Perkins <[email protected]> * Define version catalog Signed-off-by: Craig Perkins <[email protected]> * Use libraries Signed-off-by: Craig Perkins <[email protected]> * Downgrade purposefully Signed-off-by: Craig Perkins <[email protected]> * Add mavenCentral Signed-off-by: Craig Perkins <[email protected]> * Try w/o libraries section Signed-off-by: Craig Perkins <[email protected]> * reinstate Signed-off-by: Craig Perkins <[email protected]> * Remove version.properties Signed-off-by: Craig Perkins <[email protected]> * Update syntax Signed-off-by: Craig Perkins <[email protected]> * Change back to weekly Signed-off-by: Craig Perkins <[email protected]> * Add grpc Signed-off-by: Craig Perkins <[email protected]> * Get relative to project root. Relative path not working on windows bc windows had gradle wrapper path Signed-off-by: Craig Perkins <[email protected]> * Add minimal version.properties with only opensearch version to accommodate external references Signed-off-by: Craig Perkins <[email protected]> * singularize version.properties Signed-off-by: Craig Perkins <[email protected]> * Get rootDir Signed-off-by: Craig Perkins <[email protected]> * Fix issue loading snapshot Signed-off-by: Craig Perkins <[email protected]> * Limit logic to generating version.properties file within buildSrc Signed-off-by: Craig Perkins <[email protected]> * Remove unused exports Signed-off-by: Craig Perkins <[email protected]> * Add import Signed-off-by: Craig Perkins <[email protected]> * Remove unused code Signed-off-by: Craig Perkins <[email protected]> * Remove mavenCentral from publication section Signed-off-by: Craig Perkins <[email protected]> * Add to CHANGELOG Signed-off-by: Craig Perkins <[email protected]> * Update reactor-netty version Signed-off-by: Craig Perkins <[email protected]> * Only keep versions section in toml Signed-off-by: Craig Perkins <[email protected]> * Replaces versions catalog TOML parsing with Gradle's VersionCatalogsExtension Signed-off-by: Andriy Redko <[email protected]> * Update bundled_jdk Signed-off-by: Craig Perkins <[email protected]> * Update bytebuddy and mockito Signed-off-by: Craig Perkins <[email protected]> --------- Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Andriy Redko <[email protected]> Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]> Co-authored-by: Andriy Redko <[email protected]> Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]> (cherry picked from commit af7a067) * Update os version in libs.versions.toml Signed-off-by: Craig Perkins <[email protected]> * tdigest 3.2 Signed-off-by: Craig Perkins <[email protected]> * Update libs.versions.toml Signed-off-by: Andriy Redko <[email protected]> * Update libs.versions.toml Signed-off-by: Andriy Redko <[email protected]> --------- Signed-off-by: Craig Perkins <[email protected]> Signed-off-by: Andriy Redko <[email protected]> Co-authored-by: Andriy Redko <[email protected]> Co-authored-by: Andriy Redko <[email protected]>
1 parent b2e30b0 commit 037c3ea

File tree

5 files changed

+99
-84
lines changed

5 files changed

+99
-84
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55

66
## [Unreleased 2.x]
77
### Added
8+
- Switch from `buildSrc/version.properties` to Gradle version catalog (`gradle/libs.versions.toml`) to enable dependabot to perform automated upgrades on common libs ([#16284](https://github.com/opensearch-project/OpenSearch/pull/16284))
89

910
### Dependencies
1011

buildSrc/build.gradle

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if (project == rootProject) {
5757
// we update the version property to reflect if we are building a snapshot or a release build
5858
// we write this back out below to load it in the Build.java which will be shown in rest main action
5959
// to indicate this being a snapshot build or a release build.
60-
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project.file('version.properties'))
60+
Properties props = VersionPropertiesLoader.loadBuildSrcVersion(project)
6161
version = props.getProperty("opensearch")
6262

6363
def generateVersionProperties = tasks.register("generateVersionProperties", WriteProperties) {
@@ -285,15 +285,19 @@ if (project != rootProject) {
285285
}
286286
}
287287

288-
// Define this here because we need it early.
288+
// Define this here because we need it early. It uses VersionCatalogsExtension to extract all versions
289+
// and converts to a Java Properties object
289290
class VersionPropertiesLoader {
290-
static Properties loadBuildSrcVersion(File input) throws IOException {
291+
static Properties loadBuildSrcVersion(Project project) throws IOException {
291292
Properties props = new Properties();
292-
InputStream is = new FileInputStream(input)
293-
try {
294-
props.load(is)
295-
} finally {
296-
is.close()
293+
294+
var catalogs = project.extensions.getByType(VersionCatalogsExtension)
295+
var libs = catalogs.named("libs")
296+
libs.getVersionAliases().forEach {
297+
libs.findVersion(it).ifPresent { v ->
298+
// Gradle replaces '_' with '.' so 'google_http_client' becomes 'google.http.client' instead
299+
props.setProperty(it.replaceAll("[.]", "_"), v.requiredVersion)
300+
}
297301
}
298302
loadBuildSrcVersion(props, System.getProperties())
299303
return props

buildSrc/settings.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@
1010
*/
1111

1212
include 'reaper'
13+
14+
dependencyResolutionManagement {
15+
versionCatalogs {
16+
libs {
17+
from(files("../gradle/libs.versions.toml"))
18+
}
19+
}
20+
}

buildSrc/version.properties

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1 @@
11
opensearch = 2.19.0
2-
lucene = 9.12.0
3-
4-
bundled_jdk_vendor = adoptium
5-
bundled_jdk = 21.0.5+11
6-
7-
# optional dependencies
8-
spatial4j = 0.7
9-
jts = 1.15.0
10-
jackson = 2.17.2
11-
jackson_databind = 2.17.2
12-
snakeyaml = 2.1
13-
icu4j = 75.1
14-
supercsv = 2.4.0
15-
log4j = 2.21.0
16-
slf4j = 1.7.36
17-
asm = 9.7
18-
jettison = 1.5.4
19-
woodstox = 6.4.0
20-
kotlin = 1.7.10
21-
antlr4 = 4.13.1
22-
guava = 32.1.1-jre
23-
protobuf = 3.25.5
24-
jakarta_annotation = 1.3.5
25-
google_http_client = 1.44.1
26-
tdigest = 3.2
27-
hdrhistogram = 2.2.2
28-
grpc = 1.68.0
29-
30-
# when updating the JNA version, also update the version in buildSrc/build.gradle
31-
jna = 5.13.0
32-
33-
netty = 4.1.114.Final
34-
joda = 2.12.7
35-
36-
# project reactor
37-
reactor_netty = 1.1.23
38-
reactor = 3.5.20
39-
40-
# client dependencies
41-
httpclient = 4.5.14
42-
httpcore = 4.4.16
43-
httpasyncclient = 4.1.5
44-
commonslogging = 1.2
45-
commonscodec = 1.16.1
46-
commonslang = 3.14.0
47-
commonscompress = 1.26.1
48-
commonsio = 2.16.0
49-
# plugin dependencies
50-
aws = 2.20.86
51-
reactivestreams = 1.0.4
52-
53-
# when updating this version, you need to ensure compatibility with:
54-
# - plugins/ingest-attachment (transitive dependency, check the upstream POM)
55-
# - distribution/tools/plugin-cli
56-
bouncycastle=1.78
57-
# test dependencies
58-
randomizedrunner = 2.7.1
59-
junit = 4.13.2
60-
hamcrest = 2.1
61-
mockito = 5.14.1
62-
objenesis = 3.2
63-
bytebuddy = 1.15.4
64-
65-
# benchmark dependencies
66-
jmh = 1.35
67-
68-
# compression
69-
zstd = 1.5.5-5
70-
71-
jzlib = 1.1.3
72-
73-
resteasy = 6.2.4.Final
74-
75-
# opentelemetry dependencies
76-
opentelemetry = 1.41.0
77-
opentelemetrysemconv = 1.27.0-alpha

gradle/libs.versions.toml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
[versions]
2+
opensearch = "2.19.0"
3+
lucene = "9.12.0"
4+
5+
bundled_jdk_vendor = "adoptium"
6+
bundled_jdk = "21.0.5+11"
7+
8+
# optional dependencies
9+
spatial4j = "0.7"
10+
jts = "1.15.0"
11+
jackson = "2.17.2"
12+
jackson_databind = "2.17.2"
13+
snakeyaml = "2.1"
14+
icu4j = "75.1"
15+
supercsv = "2.4.0"
16+
log4j = "2.21.0"
17+
slf4j = "1.7.36"
18+
asm = "9.7"
19+
jettison = "1.5.4"
20+
woodstox = "6.4.0"
21+
kotlin = "1.7.10"
22+
antlr4 = "4.13.1"
23+
guava = "32.1.1-jre"
24+
protobuf = "3.25.5"
25+
jakarta_annotation = "1.3.5"
26+
google_http_client = "1.44.1"
27+
tdigest = "3.2"
28+
hdrhistogram = "2.2.2"
29+
grpc = "1.68.0"
30+
31+
# when updating the JNA version, also update the version in buildSrc/build.gradle
32+
jna = "5.13.0"
33+
34+
netty = "4.1.114.Final"
35+
joda = "2.12.7"
36+
37+
# project reactor
38+
reactor_netty = "1.1.23"
39+
reactor = "3.5.20"
40+
41+
# client dependencies
42+
httpclient = "4.5.14"
43+
httpcore = "4.4.16"
44+
httpasyncclient = "4.1.5"
45+
commonslogging = "1.2"
46+
commonscodec = "1.16.1"
47+
commonslang = "3.14.0"
48+
commonscompress = "1.26.1"
49+
commonsio = "2.16.0"
50+
# plugin dependencies
51+
aws = "2.20.86"
52+
reactivestreams = "1.0.4"
53+
54+
# when updating this version, you need to ensure compatibility with:
55+
# - plugins/ingest-attachment (transitive dependency, check the upstream POM)
56+
# - distribution/tools/plugin-cli
57+
bouncycastle="1.78"
58+
# test dependencies
59+
randomizedrunner = "2.7.1"
60+
junit = "4.13.2"
61+
hamcrest = "2.1"
62+
mockito = "5.14.1"
63+
objenesis = "3.2"
64+
bytebuddy = "1.15.4"
65+
66+
# benchmark dependencies
67+
jmh = "1.35"
68+
69+
# compression
70+
zstd = "1.5.5-5"
71+
72+
jzlib = "1.1.3"
73+
74+
resteasy = "6.2.4.Final"
75+
76+
# opentelemetry dependencies
77+
opentelemetry = "1.41.0"
78+
opentelemetrysemconv = "1.27.0-alpha"

0 commit comments

Comments
 (0)