-
Notifications
You must be signed in to change notification settings - Fork 125
/
build.gradle
103 lines (90 loc) · 3.86 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import org.apache.tools.ant.taskdefs.condition.Os
import java.nio.file.Files
apply plugin: 'opensearch.testclusters'
apply plugin: 'opensearch.build'
apply plugin: 'opensearch.rest-test'
// Disable a few tasks that come with build
build.enabled = false
integTest.enabled = false
test.enabled = false
assemble.enabled = false
dependenciesInfo.enabled = false
dependencies {
api "org.opensearch:opensearch:${opensearch_version}"
compileOnly "org.opensearch.plugin:opensearch-scripting-painless-spi:${versions.opensearch}"
api group: 'commons-lang', name: 'commons-lang', version: '2.6'
api "org.apache.logging.log4j:log4j-api:${versions.log4j}"
api "org.apache.logging.log4j:log4j-core:${versions.log4j}"
testImplementation "org.opensearch.test:framework:${opensearch_version}"
testImplementation(testFixtures(rootProject))
}
def tmp_dir = project.file('build/private/artifact_tmp').absoluteFile
tmp_dir.mkdirs()
String default_bwc_version = System.getProperty("bwc.version")
String knn_bwc_version = System.getProperty("tests.bwc.version", default_bwc_version)
boolean isSnapshot = knn_bwc_version.contains("-SNAPSHOT")
String knn_bwc_version_no_qualifier = isSnapshot ? knn_bwc_version - "-SNAPSHOT" : knn_bwc_version
String os_platform = "linux"
String artifact_type = "tar"
String file_ext = "tar.gz"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
os_platform = "windows"
artifact_type = "zip"
file_ext = "zip"
}
// Task to pull k-NN plugin from archive
task pullBwcPlugin {
doFirst {
File[] tempFiles = tmp_dir.listFiles()
for (File child : tempFiles) {
if (child.exists() && child.toString().contains("opensearch-")) {
Files.delete(child.toPath());
}
}
}
doLast {
ext{
if (isSnapshot) {
srcUrl = "https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/${knn_bwc_version_no_qualifier}/latest/${os_platform}/x64/${artifact_type}/dist/opensearch/opensearch-${knn_bwc_version_no_qualifier}-${os_platform}-x64.${file_ext}"
} else {
srcUrl = "https://artifacts.opensearch.org/releases/bundle/opensearch/${knn_bwc_version}/opensearch-${knn_bwc_version}-${os_platform}-x64.${file_ext}"
}
}
ant.get(
src: srcUrl,
dest: tmp_dir.absolutePath,
httpusecaches: false
)
copy {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
from zipTree(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version_no_qualifier}-${os_platform}-x64.${file_ext}"))
} else {
from tarTree(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version_no_qualifier}-${os_platform}-x64.${file_ext}"))
}
into tmp_dir.absolutePath
}
copy {
from(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version_no_qualifier}", "plugins", "opensearch-knn"))
into java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn")
}
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version_no_qualifier}"), java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-${knn_bwc_version_no_qualifier}-${os_platform}-x64.${file_ext}")
}
}
// Task to zip plugin from archive
task zipBwcPlugin(type: Zip) {
dependsOn "pullBwcPlugin"
from(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn"))
destinationDirectory = tmp_dir
archiveFileName = "opensearch-knn-${knn_bwc_version_no_qualifier}.zip"
doLast {
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-knn")
}
}
task bwcTestSuite {
dependsOn ":qa:restart-upgrade:testRestartUpgrade"
dependsOn ":qa:rolling-upgrade:testRollingUpgrade"
}