mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-07 05:28:34 +00:00
Now that ML binaries are public, there is no longer a need to use the s3 client to access the bucket, since creds are not needed. This commit also moves the cpp snapshot project under the ml module, since it is specific to that and does not need to clutter the plugin dir. Original commit: elastic/x-pack-elasticsearch@51e77da4ac
53 lines
1.8 KiB
Groovy
53 lines
1.8 KiB
Groovy
import java.net.HttpURLConnection
|
|
import org.elasticsearch.gradle.VersionProperties
|
|
|
|
apply plugin: 'distribution'
|
|
|
|
ext.version = VersionProperties.elasticsearch
|
|
|
|
// This project pulls a snapshot version of the ML cpp artifacts and sets that as the artifact
|
|
// for this project so it can be used with dependency substitution.
|
|
|
|
void getZip(File snapshotZip) {
|
|
String zipUrl = "http://prelert-artifacts.s3.amazonaws.com/maven/org/elasticsearch/ml/ml-cpp/${version}/ml-cpp-${version}.zip"
|
|
File snapshotMd5 = new File(snapshotZip.toString() + '.md5')
|
|
HttpURLConnection conn = (HttpURLConnection) new URL(zipUrl).openConnection();
|
|
|
|
// do a HEAD first to check the zip hash against the local file
|
|
conn.setRequestMethod('HEAD');
|
|
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
|
throw new GradleException('ML cpp snapshot does not exist')
|
|
}
|
|
|
|
String remoteMd5 = conn.getHeaderField('ETag')
|
|
if (snapshotZip.exists()) {
|
|
// do a HEAD first to check the zip hash against the local file
|
|
String localMd5 = snapshotMd5.getText('UTF-8')
|
|
if (remoteMd5.equals(localMd5)) {
|
|
logger.info('Using cached ML snapshot')
|
|
return
|
|
}
|
|
}
|
|
|
|
snapshotZip.bytes = new URL(zipUrl).bytes
|
|
snapshotMd5.setText(remoteMd5, 'UTF-8')
|
|
}
|
|
|
|
File snapshotZip = new File(projectDir, ".cache/ml-cpp-${version}.zip")
|
|
task downloadMachineLearningSnapshot {
|
|
onlyIf {
|
|
// skip if machine-learning-cpp is being built locally
|
|
findProject(':machine-learning-cpp') == null &&
|
|
// skip for offline builds - just rely on the artifact already having been downloaded before here
|
|
project.gradle.startParameter.isOffline() == false
|
|
}
|
|
doFirst {
|
|
snapshotZip.parentFile.mkdirs()
|
|
getZip(snapshotZip)
|
|
}
|
|
}
|
|
|
|
artifacts {
|
|
'default' file: snapshotZip, name: 'ml-cpp', type: 'zip', builtBy: downloadMachineLearningSnapshot
|
|
}
|