-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathbuild.gradle
More file actions
142 lines (121 loc) · 5 KB
/
Copy pathbuild.gradle
File metadata and controls
142 lines (121 loc) · 5 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
import org.apache.tools.ant.taskdefs.condition.Os
import java.nio.file.Files
import java.nio.file.Paths
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
def opensearch_jvector_build = knn_bwc_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
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"
}
allprojects {
java {
sourceCompatibility = java_release_version.toInteger()
targetCompatibility = java_release_version.toInteger()
}
}
tasks.register("downloadFromMaven", Copy) {
mustRunAfter pullBwcPlugin
def mavenSnapshotRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
def groupId = "org.opensearch.plugin"
def artifactId = "opensearch-jvector-plugin"
if (isSnapshot) {
def repos = project.getRepositories();
MavenArtifactRepository opensearchRepo = repos.maven(repo -> {
repo.setName("opensearch-snapshots");
repo.setUrl(mavenSnapshotRepoUrl);
});
}
configurations {
pluginArtifact {
}
}
dependencies {
pluginArtifact("${groupId}:${artifactId}:${opensearch_jvector_build}@zip")
}
from zipTree(configurations.pluginArtifact.singleFile)
into java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-jvector")
}
// Task to pull k-NN plugin from archive
task pullBwcPlugin {
doFirst {
tmp_dir.mkdirs()
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-jvector"))
into java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-jvector")
}
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 downloadFromMaven, pullBwcPlugin
from(java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-jvector"))
destinationDirectory = tmp_dir
archiveFileName = "opensearch-jvector-${knn_bwc_version_no_qualifier}.zip"
doLast {
delete java.nio.file.Path.of(tmp_dir.absolutePath, "opensearch-jvector")
}
}
task bwcTestSuite {
dependsOn ":qa:restart-upgrade:testRestartUpgrade"
dependsOn ":qa:rolling-upgrade:testRollingUpgrade"
}