forked from streamsets/datacollector-edge-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
257 lines (234 loc) · 9.34 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
plugins {
id 'com.github.blindpirate.gogradle' version '0.11.4'
id 'com.palantir.git-version' version '0.12.0-rc2'
id 'maven-publish'
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
golang {
root { it.startsWith('periph.io') }
url "https://github.com/google/periph"
}
}
golang {
goVersion = '1.13.5'
packagePath = gitPath
ignoredPackages = [
'a',
'cloud.google.com',
'common',
'github.com/envoyproxy/go-control-plane'
]
}
dependencies {
golang {
build name: 'github.com/Shopify/sarama', tag: '1.17.0'
build name: 'github.com/pierrec/lz4', tag: 'v2.0.5'
build name: 'github.com/sirupsen/logrus', tag: 'v1.0.3'
build name: 'github.com/AllenDang/w32', commit: '9a4ee0f7d224efbff75947fa7060daadccc4741c'
build name: 'github.com/BurntSushi/toml', commit: 'b26d9c308763d68093482582cea63d69be07a0f0'
build name: 'github.com/dustin/go-coap', commit: 'ddcc80675fa42611359d91a6dfa5aa57fb90e72b'
build name: 'github.com/eclipse/paho.mqtt.golang', tag: 'v1.2.0', transitive: false
build name: 'github.com/gorilla/websocket', commit: 'ea4d1f681babbce9545c9c5f3d5194a789c89f5b'
build name: 'github.com/hpcloud/tail', commit: 'a1dbeea552b7c8df4b542c66073e393de198a800'
build name: 'github.com/julienschmidt/httprouter', commit: '8c199fb6259ffc1af525cc3ad52ee60ba8359669'
build name: 'github.com/madhukard/govaluate', commit: '0646b701eef558ce8c2a058beac03dab78b81cc7'
build name: 'github.com/rcrowley/go-metrics', commit: '1f30fe9094a513ce4c700b9a54458bbb0c96996c'
build name: 'github.com/satori/go.uuid', commit: '879c5887cd475cd7864858769793b2ceb0d44feb'
build name: 'periph.io/x/periph', commit: '687bb43ba5ad417371dc0d1a1f7189119aafcede'
build name: 'github.com/robertkrimen/otto', commit: '15f95af6e78dcd2030d8195a138bd88d4f403546'
build name: 'github.com/mrjones/oauth', commit: '78d64468d6ec7b74e4b0d47cf61b4f4e288b944b'
build name: 'github.com/xinsnake/go-http-digest-auth-client', commit: '9da83de55d71220f00cbffb736dba373e6e683b1'
build name: 'github.com/hashicorp/go-cleanhttp', commit: 'd5fe4b57a186c716b0e00b8c301cbd9b4182694d'
build name: 'github.com/shirou/gopsutil', commit: '68ff0e299699630e174f9afaebb4b8c99d0520dc'
build name: 'github.com/StackExchange/wmi', commit: 'cdffdb33acae0e14efff2628f9bae377b597840e'
build name: 'github.com/go-ole/go-ole', commit: 'a1ec82a652ebc7e784d7df887cfb31061aeabbcc'
build name: 'github.com/shirou/w32', commit: 'bb4de0191aa41b5507caa14b0650cdbddcd9280b'
build name: 'github.com/icrowley/fake', commit: '4178557ae428460c3780a381c824a1f3aceb6325'
build name: 'github.com/kardianos/service', commit: '4c239ee84e7bb93441b1b6a3f2db62d40e0e6cbd'
build name: 'github.com/tensorflow/tensorflow/tensorflow/go', tag: '1.10.0', transitive: false
build name: 'github.com/spf13/cast', tag: 'v1.2.0', transitive: false
build name: 'github.com/Workiva/go-datastructures', tag: 'v1.0.50', transitive: false
build name: 'github.com/aws/aws-sdk-go', tag: 'v1.15.81'
build name: 'github.com/Azure/azure-amqp-common-go', tag: 'v1.1.4', transitive: false
build name: 'github.com/Azure/azure-pipeline-go', tag: 'v0.1.8', transitive: false
build name: 'github.com/Azure/azure-sdk-for-go', tag: 'v21.3.0', transitive: false
build name: 'github.com/Azure/go-autorest', tag: 'v11.1.1', transitive: false
build name: 'github.com/dgrijalva/jwt-go', tag: 'v3.1.0', transitive: false
build name: 'github.com/jpillora/backoff', tag: 'v1.0.0', transitive: false
build name: 'pack.ag/amqp', tag: 'v0.11.0', transitive: false
build name: 'github.com/mitchellh/mapstructure', tag: 'v1.1.2', transitive: false
build name: 'go.opencensus.io', tag: 'v0.18.0', transitive: false
build name: 'github.com/Azure/azure-event-hubs-go', tag: 'v1.3.0', transitive: false
build name: 'github.com/amenzhinsky/iothub', commit: 'dbe5ff5f148f9eff39c72c43eab6e6f4c9ed3575', transitive: false
build name: 'golang.org/x/build', commit: 'e707fb0ed35eab3beb48321e5ee37ff7ca438f28', transitive: false
build name: 'golang.org/x/sys', commit: 'b397fe3ad8ed895c98fa54584f61835a88e65ff5', transitive: false
build name: 'github.com/influxdata/influxdb1-client', commit: '8bf82d3c094dc06be9da8e5bf9d3589b6ea032ae', transitive: false
build name: 'k8s.io/client-go', tag: 'v0.17.0', transitive: false
}
}
def getLdFlags() {
def additionalFlag = ''
if (project.hasProperty('release')) {
additionalFlag = ' -s -w'
}
final buildDate = new Date().format("yyyy-MM-dd'T'HHmmss'Z'")
final X_CONTAINER_COMMON_PATH = " -X ${gitPath}/container/common"
"\"" + X_CONTAINER_COMMON_PATH + ".Version=${version}" +
X_CONTAINER_COMMON_PATH + ".BuiltBy=" + System.properties['user.name'].replaceAll("\\s", "") +
X_CONTAINER_COMMON_PATH + ".BuiltDate=" + buildDate +
X_CONTAINER_COMMON_PATH + ".BuiltRepoSha=" + gitVersion() + additionalFlag + "\""
}
def getTagsParameter() {
return project.hasProperty("includeStage") ? " -tags '${includeStage}' " : ""
}
final tagsParameter = getTagsParameter()
/**
* Helper to convert platforms to camel case
* @param text
* @return
*/
static String toCamelCase(String text) {
return text.replaceAll("(-)([A-Za-z0-9])", { Object[] it -> it[2].toUpperCase() })
}
def targetPlatforms = platforms.split(',') as List
goBuild {
targetPlatform = targetPlatforms
go "build ${tagsParameter} -ldflags ${getLdFlags()} -o " + 'build/bin/${GOOS}-${GOARCH}/edge\${GOEXE}' + " ${gitPath}"
}
// add extra path to delete since we use a custom output directory
goClean {
delete 'dist'
}
goVet {
continueOnFailure = true
}
CopySpec standardDistribution(String platform) {
copySpec {
from("$projectDir/resources") {
includeEmptyDirs = true
include('etc/', 'data/', 'log/', 'QUICKSTART.md')
exclude('data/**/*.png', 'data/**/*.md')
}
into('bin') {
from "$buildDir/bin/${platform}"
fileMode 0755
}
}
}
// Creates distribution tasks for each target platform
targetPlatforms.findAll { !it.contains('windows') }.each { platform ->
def camelPlatform = toCamelCase(platform)
def distTask = task "${camelPlatform}DistTar"(type: Tar) {
group 'Distribution'
description "Creates a distribution tarball for $platform"
baseName appName + "-" + project.version
classifier platform
extension 'tgz'
destinationDir file('dist')
compression Compression.GZIP
into('streamsets-datacollector-edge') {
with standardDistribution(platform)
}
dependsOn "build${camelPlatform.capitalize()}", goCheck
}
publishing {
publications {
maven(MavenPublication) {
artifact(distTask) {
groupId "com.streamsets"
artifactId appName
}
}
}
}
}
targetPlatforms.findAll { it.contains('windows') }.each { platform ->
def camelPlatform = toCamelCase(platform)
def distTask = task "${camelPlatform}DistZip"(type: Zip) {
group 'Distribution'
description "Creates a distribution zip for $platform"
baseName appName + "-" + project.version
classifier platform
extension 'zip'
destinationDir file('dist')
into('streamsets-datacollector-edge') {
with standardDistribution(platform)
}
dependsOn "build${camelPlatform.capitalize()}", goCheck
}
publishing {
publications {
maven(MavenPublication) {
artifact(distTask) {
groupId "com.streamsets"
artifactId appName
}
}
}
}
}
// Creates tasks for creating an unarchived distribution in dist (preserving existing behavior)
// Will overwrite existing binaries if present, this could be changed to install into platform-specific
// output directories.
targetPlatforms.each { platform ->
def camelPlatform = toCamelCase(platform).capitalize()
task "install${camelPlatform}"(type: Copy) {
group 'Distribution'
description 'Installs a distribution into the dist directory as-is'
destinationDir file("$projectDir/dist")
with standardDistribution(platform)
dependsOn "build${camelPlatform}"
}
}
// aggregates all tar distributions into a task
task distTar {
group 'Distribution'
description 'Builds all tarball distributions'
dependsOn tasks.withType(Tar)
}
// aggregates all zip distributions into a task
task distZip {
group 'Distribution'
description 'Builds all zip distributions'
dependsOn tasks.withType(Zip)
}
// aggregates all distribution tasks (in case zip is added)
task dist {
group 'Distribution'
description 'Builds all distributions'
dependsOn distTar, distZip
}
publishing {
// Configure Publishing repository
// Need the following env variables MAVEN_REPO, MAVEN_USER, MAVEN_PASSWORD
def repoUrl = System.env['MAVEN_REPO']
if (repoUrl != null) {
repositories {
maven {
url repoUrl
credentials {
username = System.env['MAVEN_USER']
password = System.env['MAVEN_PASSWORD']
}
}
}
}
}
// Kept for backward compatibility
task release {
dependsOn publish
}
// Requirements to run this task - A windows machine, go-msi and wix tools
// Setup Steps - https://mh-cbon.github.io/go-msi/
task buildMSI {
dependsOn installWindowsAmd64
doLast {
exec {
workingDir 'dist'
commandLine 'cmd', '/c', 'go-msi make --path ../resources/windows/wix.json --src ../resources/windows/templates --msi ./${appName}.msi --version ${project.version}'
}
}
}