forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
190 lines (164 loc) · 6.67 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
id 'de.undercouch.download' version '4.1.2' apply false
}
import com.mgd.core.gradle.S3Upload
subprojects {
apply plugin: 'de.undercouch.download'
apply plugin: 'distribution'
configurations {
allDependencyJarsFromMain {
canBeConsumed = false
canBeResolved = true
}
}
dependencies {
/* required to resolve below issue with aws sdk
JAXB is unavailable. Will fallback to SDK implementation which may be less performant
*/
implementation 'javax.xml.bind:jaxb-api:2.3.1'
/**
* Creates a configuration on the data-prepper-main runtimeClasspath.
* https://docs.gradle.org/current/userguide/cross_project_publications.html
*/
allDependencyJarsFromMain(project(path: ':data-prepper-main', configuration: 'allDependencyJars'))
}
ext {
archiveToTar = this.&archiveToTar
}
def supportedArchitectures = architectures.get(it.name) as String[]
def platform = it.name
//For each subproject and its supported architecture - Add distribution and upload tasks
supportedArchitectures.each {
def architecture = it
def distName = "${platform}${architecture}" //eg linuxarm64
def distNameWithJDK = "${distName}WithJDK"
def downloadJDKTask = "download${architecture}JDK"
def installTaskName = "install${distName.capitalize()}Dist"
//This adds two distributions for each supported architecture e.g. linuxarm64DistTar, linuxarm64WithJDKDistTar
distributions {
"${distName}" {
distributionBaseName = "${project.rootProject.name}-${project.rootProject.version}-${platform}-${architecture}"
contents {
with archiveToTar()
into('bin') {
from("data-prepper-${architecture}.sh").rename("data-prepper-${architecture}.sh", "data-prepper")
fileMode 0755
}
}
}
"${distNameWithJDK}" {
distributionBaseName = "${project.rootProject.name}-jdk-${project.rootProject.version}-${platform}-${architecture}"
contents {
with archiveToTar()
into('openjdk') {
from tarTree("${buildDir}/${platform}${architecture}/openjdk/openjdk.tar.gz")
}
into('bin') {
from("data-prepper-jdk-${architecture}.sh").rename("data-prepper-jdk-${architecture}.sh", "data-prepper")
fileMode 0755
}
}
}
}
//by default distribution plugin adds project version to archive name, removing it
distTar {
project.version = ""
}
tasks.getByName(installTaskName) {
dependsOn ':release:releasePrerequisites'
}
assemble.dependsOn(installTaskName)
//Adds one task per supported architecture for downloading appropriate JDK e.g. downloadarm64JDK
tasks.create("${downloadJDKTask}", Download, {
src jdkSources.get(platform + '_' + architecture)
dest "${buildDir}/${platform}${architecture}/openjdk/openjdk.tar.gz"
overwrite false
})
}
tasks.withType(Zip) {
enabled false
}
tasks.withType(Tar) {
dependsOn ':release:releasePrerequisites'
compression = Compression.GZIP
archiveExtension = 'tar.gz'
}
tasks.create("${platform}Tar") {
supportedArchitectures.each {
dependsOn "${platform}${it}DistTar"
dependsOn "${platform}${it}WithJDKDistTar"
}
}
afterEvaluate {
supportedArchitectures.each {
def platformWithArchitecture = "${platform}${it}"
def tarTask = tasks.getByName("${platformWithArchitecture}DistTar")
def tarWithJDKTask = tasks.getByName("${platformWithArchitecture}WithJDKDistTar")
def destinationKeyPath = "${archiveRootKey}/archive"
tasks.getByName("${platformWithArchitecture}WithJDKDistTar").dependsOn("download${it}JDK")
tasks.create(name: "upload${platformWithArchitecture}TarToS3", type: S3Upload) {
dependsOn tarTask.name
file = tarTask.archiveFile.get().asFile.absolutePath
bucket = awsS3Bucket
key = "${destinationKeyPath}/${tarTask.archiveFileName.get()}"
}
tasks.create(name: "upload${platformWithArchitecture}TarWithJDKToS3", type: S3Upload) {
dependsOn tarWithJDKTask.name
file = tarWithJDKTask.archiveFile.get().asFile.absolutePath
bucket = awsS3Bucket
key = "${destinationKeyPath}/${tarWithJDKTask.archiveFileName.get()}"
}
}
tasks.create('uploadToS3') {
tasks.withType(S3Upload).each {
dependsOn it.name
}
}
}
}
CopySpec archiveToTar() {
return copySpec {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
into('lib') {
from project(':data-prepper-main').jar.archivePath
from configurations.runtimeClasspath
//from allDependencyJarsFromMain(project(path: ':data-prepper-main', configuration: 'allDependencyJars')).runtimeClasspath
//from project(':data-prepper-main').configurations.allDependencyJars
fileMode 0755
}
into('examples') {
from("${rootDir}/examples")
dirMode 0750
fileMode 0755
}
into('config') {
from("${rootDir}/shared-config/log4j2-rolling.properties")
from("${rootDir}/examples/config/example-data-prepper-config.yaml")
.rename("example-data-prepper-config.yaml", "data-prepper-config.yaml")
from("${rootDir}/examples/certificates/default_certificate.pem")
from("${rootDir}/examples/certificates/default_private_key.pem")
}
into('pipelines') {
from("${rootDir}/examples/config/pipelines-readme.txt").rename("pipelines-readme.txt", "README")
}
into('') {
from("${rootDir}/LICENSE")
from("${rootDir}/NOTICE")
from("${rootDir}/THIRD-PARTY")
fileMode 0755
}
}
}
task uploadArchives {
subprojects.each { dependsOn ':release:archives:' + it.name + ':uploadToS3' }
}
task buildTar {
subprojects.each { dependsOn ':release:archives:' + it.name + ':' + it.name + 'Tar' }
}
task buildArchives {
dependsOn buildTar
}