forked from elastic/ml-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.gradle
106 lines (90 loc) · 3.75 KB
/
upload.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
104
105
description = 'Uploads the Machine Learning native binaries to s3'
import org.elastic.gradle.UploadS3Task
import org.gradle.util.GradleVersion
import org.gradle.util.DistributionLocator
import static org.gradle.api.tasks.wrapper.Wrapper.DistributionType
boolean snapshot = "true".equals(System.getProperty("build.snapshot", "true"));
allprojects {
group = 'org.elasticsearch.ml'
version = elasticsearchVersion
if (snapshot) {
version += '-SNAPSHOT'
}
}
String artifactGroupPath = project.group.replaceAll("\\.", "/")
String envMlAwsAccessKey = System.env.ML_AWS_ACCESS_KEY
if (envMlAwsAccessKey != null) {
project.ext.mlAwsAccessKey = envMlAwsAccessKey
} else if (project.hasProperty("ML_AWS_ACCESS_KEY")) {
project.ext.mlAwsAccessKey = ML_AWS_ACCESS_KEY
}
String envMlAwsSecretKey = System.env.ML_AWS_SECRET_KEY
if (envMlAwsSecretKey != null) {
project.ext.mlAwsSecretKey = envMlAwsSecretKey
} else if (project.hasProperty("ML_AWS_SECRET_KEY")) {
project.ext.mlAwsSecretKey = ML_AWS_SECRET_KEY
}
allprojects {
repositories {
if (System.getProperty("repos.mavenlocal") != null) {
// with -Drepos.mavenlocal=true we can force checking the local .m2 repo which is useful for building against
// elasticsearch snapshots
mavenLocal()
}
maven {
url "s3://prelert-artifacts/maven"
credentials(AwsCredentials) {
accessKey "${mlAwsAccessKey}"
secretKey "${mlAwsSecretKey}"
}
}
}
}
configurations {
archives
}
dependencies {
archives group: "${project.group}", name: "${artifactName}", version:"${project.version}", classifier: 'darwin-x86_64', ext: 'zip'
archives group: "${project.group}", name: "${artifactName}", version:"${project.version}", classifier: 'linux-x86_64', ext: 'zip'
archives group: "${project.group}", name: "${artifactName}", version:"${project.version}", classifier: 'windows-x86_64', ext: 'zip'
}
task upload(type: UploadS3Task) {
bucket 'prelert-artifacts'
// Only upload the platform-specific artifacts in this task
def zipFileDir = fileTree(dir: "${projectDir}/build/distributions").matching { include "*-x86_64.zip" }
for (zipFile in zipFileDir) {
upload zipFile, "maven/${artifactGroupPath}/${artifactName}/${project.version}/${zipFile.name}"
}
description = 'Upload C++ zips to S3 Bucket'
}
task buildUberZip(type: Zip) {
dependsOn configurations.archives
baseName = "$artifactName"
// The 'from' section must be a closure, otherwise the dependencies will be downloaded during
// the configuration phase, which is not what we want when simply using the 'upload' task
from {
configurations.archives.collect {
from(zipTree(it))
}
duplicatesStrategy 'exclude'
}
destinationDir = file("${buildDir}/distributions")
version = project.version
description = 'Download previously created platform-specific C++ zips and combine them into an uber zip'
}
task uberUpload(type: UploadS3Task, dependsOn: buildUberZip) {
bucket 'prelert-artifacts'
upload buildUberZip.outputs.files.singleFile, "maven/${artifactGroupPath}/${artifactName}/${project.version}/${buildUberZip.outputs.files.singleFile.name}"
description = 'Upload C++ uber zip to S3 Bucket'
}
task wrapper(type: Wrapper) {
distributionType = DistributionType.ALL
doLast {
final DistributionLocator locator = new DistributionLocator()
final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
final URI distributionUri = locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
final URI sha256Uri = new URI(distributionUri.toString() + ".sha256")
final String sha256Sum = new String(sha256Uri.toURL().bytes)
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
}
}