Skip to content

Commit 7a38664

Browse files
authored
Fix doctest job-scheduler dependency resolution for 3.8.0 (opensearch-project#5540)
Signed-off-by: Simeon Widdis <sawiddis@amazon.com>
1 parent 2850d6e commit 7a38664

1 file changed

Lines changed: 21 additions & 60 deletions

File tree

doctest/build.gradle

Lines changed: 21 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ plugins {
1515

1616
apply plugin: 'opensearch.testclusters'
1717

18+
configurations {
19+
zipArchive
20+
}
21+
22+
repositories {
23+
mavenLocal()
24+
maven { url "https://ci.opensearch.org/maven2/" }
25+
mavenCentral()
26+
}
27+
28+
dependencies {
29+
zipArchive group: 'org.opensearch.plugin', name:'opensearch-job-scheduler', version: "${opensearch_build}"
30+
}
31+
1832
def path = project(':').projectDir
1933
// temporary fix, because currently we are under migration to new architecture. Need to run ./gradlew run from
2034
// plugin module, and will only build ppl in it.
@@ -156,19 +170,13 @@ check.dependsOn doctest
156170
clean.dependsOn(cleanBootstrap)
157171
clean.dependsOn(stopPrometheus)
158172

159-
// 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT
160-
String opensearch_no_snapshot = opensearch_version.replace('-SNAPSHOT', '')
161-
String[] version_tokens = opensearch_no_snapshot.tokenize('-')
162-
String opensearch_build = version_tokens[0] + '.0'
163-
if (version_tokens.length > 1) {
164-
opensearch_build += '-' + version_tokens[1]
173+
def getJobSchedulerPlugin() {
174+
provider { (RegularFile) (() ->
175+
configurations.zipArchive.asFileTree.matching {
176+
include '**/opensearch-job-scheduler*'
177+
}.singleFile )
178+
}
165179
}
166-
String mlCommonsRemoteFile = 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/' + opensearch_no_snapshot + '/latest/linux/x64/tar/builds/opensearch/plugins/opensearch-ml-' + opensearch_build + '.zip'
167-
String mlCommonsPlugin = 'opensearch-ml'
168-
169-
String bwcOpenSearchJSDownload = 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/' + opensearch_no_snapshot + '/latest/linux/x64/tar/builds/' +
170-
'opensearch/plugins/opensearch-job-scheduler-' + opensearch_build + '.zip'
171-
String jsPlugin = 'opensearch-job-scheduler'
172180

173181
testClusters {
174182
docTestCluster {
@@ -194,7 +202,7 @@ testClusters {
194202
}
195203
}))
196204
*/
197-
plugin(getJobSchedulerPlugin(jsPlugin, bwcOpenSearchJSDownload))
205+
plugin(getJobSchedulerPlugin())
198206
plugin ':opensearch-sql-plugin'
199207
testDistribution = 'archive'
200208
}
@@ -203,50 +211,3 @@ tasks.register("runRestTestCluster", RunTask) {
203211
description = 'Runs OpenSearch SQL plugin'
204212
useCluster testClusters.docTestCluster;
205213
}
206-
207-
208-
def getJobSchedulerPlugin(String jsPlugin, String bwcOpenSearchJSDownload) {
209-
return provider(new Callable<RegularFile>() {
210-
@Override
211-
RegularFile call() throws Exception {
212-
return new RegularFile() {
213-
@Override
214-
File getAsFile() {
215-
// Use absolute paths
216-
String basePath = new File('.').getCanonicalPath()
217-
File dir = new File(basePath + File.separator + 'doctest' + File.separator + jsPlugin)
218-
219-
// Log the directory path for debugging
220-
println("Creating directory: " + dir.getAbsolutePath())
221-
222-
// Create directory if it doesn't exist
223-
if (!dir.exists()) {
224-
if (!dir.mkdirs()) {
225-
throw new IOException("Failed to create directory: " + dir.getAbsolutePath())
226-
}
227-
}
228-
229-
// Define the file path
230-
File f = new File(dir, jsPlugin + '-' + opensearch_build + '.zip')
231-
232-
// Download file if it doesn't exist
233-
if (!f.exists()) {
234-
println("Downloading file from: " + bwcOpenSearchJSDownload)
235-
println("Saving to file: " + f.getAbsolutePath())
236-
237-
new URL(bwcOpenSearchJSDownload).withInputStream { ins ->
238-
f.withOutputStream { it << ins }
239-
}
240-
}
241-
242-
// Check if the file was created successfully
243-
if (!f.exists()) {
244-
throw new FileNotFoundException("File was not created: " + f.getAbsolutePath())
245-
}
246-
247-
return fileTree(f.getParent()).matching { include f.getName() }.singleFile
248-
}
249-
}
250-
}
251-
})
252-
}

0 commit comments

Comments
 (0)