forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
386 lines (333 loc) · 13.8 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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id 'base'
// Enable publishing build scans
id 'com.gradle.build-scan' version '2.3' apply false
// This plugin provides a task to determine which dependencies have updates.
// Additionally, the plugin checks for updates to Gradle itself.
//
// See https://github.com/ben-manes/gradle-versions-plugin for further details.
id 'com.github.ben-manes.versions' version '0.20.0'
// Apply one top level rat plugin to perform any required license enforcement analysis
id 'org.nosphere.apache.rat' version '0.4.0'
// Enable gradle-based release management
id 'net.researchgate.release' version '2.6.0'
id 'org.apache.beam.module'
id "org.sonarqube" version "2.7"
}
/*************************************************************************************************/
// Configure the root project
// Plugins which require online access should not be enabled when running in offline mode.
if (!gradle.startParameter.isOffline()) {
apply plugin: "com.gradle.build-scan"
}
// JENKINS_HOME and BUILD_ID set automatically during Jenkins execution
def isCIBuild = ['JENKINS_HOME', 'BUILD_ID'].every System.&getenv
if (isCIBuild) {
buildScan {
// Build Scan enabled and TOS accepted for Jenkins lab build. This does not apply to builds on
// non-Jenkins machines. Developers need to separately enable and accept TOS to use build scans.
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
publishAlways()
}
}
rat {
// Set input directory to that of the root project instead of the CWD. This
// makes .gitignore rules (added below) work properly.
inputDir = project.rootDir
def exclusions = [
// Ignore files we track but do not distribute
"**/.github/**/*",
"**/package-list",
"**/test.avsc",
"**/user.avsc",
"**/test/resources/**/*.txt",
"**/test/**/.placeholder",
// Default eclipse excludes neglect subprojects
// Proto/grpc generated wrappers
"**/apache_beam/portability/api/*_pb2*.py",
"**/go/pkg/beam/**/*.pb.go",
// Ignore go.sum files, which don't permit headers
"**/go.sum",
// Ignore Go test data files
"**/go/data/**",
// VCF test files
"**/apache_beam/testing/data/vcf/*",
// JDBC package config files
"**/META-INF/services/java.sql.Driver",
// Website build files
"**/Gemfile.lock",
"**/Rakefile",
"**/.htaccess",
"website/www/site/assets/scss/_bootstrap.scss",
"website/www/site/assets/scss/bootstrap/**/*",
"website/www/site/static/images/mascot/*.ai",
"website/www/site/static/js/bootstrap*.js",
"website/www/site/static/js/bootstrap/**/*",
"website/www/site/themes",
"website/www/yarn.lock",
"website/www/package.json",
// Ignore ownership files
"ownership/**/*",
"**/OWNERS",
// Json doesn't support comments.
"**/*.json",
// Katas files
"learning/katas/**/course-remote-info.yaml",
"learning/katas/**/section-remote-info.yaml",
"learning/katas/**/lesson-remote-info.yaml",
"learning/katas/**/task-remote-info.yaml",
"learning/katas/*/IO/**/*.txt",
// test p8 file for SnowflakeIO
"sdks/java/io/snowflake/src/test/resources/test_rsa_key.p8",
// Mockito extensions
"sdks/java/io/amazon-web-services2/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker",
"sdks/java/extensions/ml/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker"
]
// Add .gitignore excludes to the Apache Rat exclusion list. We re-create the behavior
// of the Apache Maven Rat plugin since the Apache Ant Rat plugin doesn't do this
// automatically.
def gitIgnore = project(':').file('.gitignore')
if (gitIgnore.exists()) {
def gitIgnoreExcludes = gitIgnore.readLines().findAll { !it.isEmpty() && !it.startsWith('#') }
exclusions.addAll(gitIgnoreExcludes)
}
failOnError = true
excludes = exclusions
}
check.dependsOn rat
// Define root pre/post commit tasks simplifying what is needed
// to be specified on the commandline when executing locally.
// This indirection also makes Jenkins use the branch of the PR
// for the test definitions.
task javaPreCommit() {
// We need to list the model/* builds since sdks/java/core doesn't
// depend on any of the model.
dependsOn ":model:pipeline:build"
dependsOn ":model:job-management:build"
dependsOn ":model:fn-execution:build"
dependsOn ":runners:google-cloud-dataflow-java:worker:legacy-worker:build"
dependsOn ":sdks:java:core:buildNeeded"
dependsOn ":sdks:java:core:buildDependents"
dependsOn ":examples:java:preCommit"
dependsOn ":sdks:java:extensions:sql:jdbc:preCommit"
dependsOn ":sdks:java:javadoc:allJavadoc"
dependsOn ":runners:direct-java:needsRunnerTests"
dependsOn ":sdks:java:container:docker"
}
task sqlPreCommit() {
dependsOn ":sdks:java:extensions:sql:runBasicExample"
dependsOn ":sdks:java:extensions:sql:runPojoExample"
dependsOn ":sdks:java:extensions:sql:build"
dependsOn ":sdks:java:extensions:sql:buildDependents"
}
task javaPreCommitBeamZetaSQL() {
dependsOn ":sdks:java:extensions:sql:zetasql:test"
}
task javaPreCommitPortabilityApi() {
dependsOn ":runners:google-cloud-dataflow-java:worker:build"
}
task javaPostCommit() {
dependsOn ":runners:google-cloud-dataflow-java:postCommit"
dependsOn ":sdks:java:extensions:google-cloud-platform-core:postCommit"
dependsOn ":sdks:java:extensions:zetasketch:postCommit"
dependsOn ":sdks:java:io:google-cloud-platform:postCommit"
}
task sqlPostCommit() {
dependsOn ":sdks:java:extensions:sql:postCommit"
dependsOn ":sdks:java:extensions:sql:jdbc:postCommit"
dependsOn ":sdks:java:extensions:sql:datacatalog:postCommit"
}
task goPreCommit() {
dependsOn ":sdks:go:goTest"
dependsOn ":sdks:go:examples:goBuild"
dependsOn ":sdks:go:test:goBuild"
// Ensure all container Go boot code builds as well.
dependsOn ":sdks:java:container:goBuild"
dependsOn ":sdks:python:container:goBuild"
dependsOn ":sdks:go:container:goBuild"
}
task goPostCommit() {
dependsOn ":goIntegrationTests"
}
task goIntegrationTests() {
doLast {
exec {
executable 'sh'
args '-c', './sdks/go/test/run_integration_tests.sh'
}
}
dependsOn ":sdks:go:test:build"
dependsOn ":runners:google-cloud-dataflow-java:worker:shadowJar"
}
task pythonPreCommit() {
dependsOn ":sdks:python:test-suites:tox:pycommon:preCommitPyCommon"
dependsOn ":sdks:python:test-suites:tox:py2:preCommitPy2"
dependsOn ":sdks:python:test-suites:tox:py35:preCommitPy35"
dependsOn ":sdks:python:test-suites:tox:py36:preCommitPy36"
dependsOn ":sdks:python:test-suites:tox:py37:preCommitPy37"
dependsOn ":sdks:python:test-suites:tox:py38:preCommitPy38"
dependsOn ":sdks:python:test-suites:dataflow:py2:preCommitIT"
dependsOn ":sdks:python:test-suites:dataflow:py2:preCommitIT_V2"
dependsOn ":sdks:python:test-suites:dataflow:py37:preCommitIT"
dependsOn ":sdks:python:test-suites:dataflow:py37:preCommitIT_V2"
// We don't include Py35, Py36 precommit ITs to reduce quota footprint.
// We can reconsider if we ever see an issue that these suites would
// have caught. Note that the same tests will still run in postcommit.
}
task pythonDockerBuildPreCommit() {
dependsOn ":sdks:python:container:py2:docker"
dependsOn ":sdks:python:container:py35:docker"
dependsOn ":sdks:python:container:py36:docker"
dependsOn ":sdks:python:container:py37:docker"
dependsOn ":sdks:python:container:py38:docker"
}
task pythonLintPreCommit() {
dependsOn ":sdks:python:test-suites:tox:py2:lint"
dependsOn ":sdks:python:test-suites:tox:py37:lint"
}
task pythonFormatterPreCommit() {
dependsOn 'sdks:python:test-suites:tox:py38:formatter'
}
task python2PostCommit() {
dependsOn ":sdks:python:test-suites:portable:py2:crossLanguagePythonJavaKafkaIOFlink"
dependsOn ":sdks:python:test-suites:portable:py2:crossLanguageTests"
dependsOn ":sdks:python:test-suites:dataflow:py2:postCommitIT"
dependsOn ":sdks:python:test-suites:direct:py2:directRunnerIT"
dependsOn ":sdks:python:test-suites:direct:py2:hdfsIntegrationTest"
dependsOn ":sdks:python:test-suites:direct:py2:mongodbioIT"
dependsOn ":sdks:python:test-suites:portable:py2:postCommitPy2"
}
task python35PostCommit() {
dependsOn ":sdks:python:test-suites:dataflow:py35:postCommitIT"
dependsOn ":sdks:python:test-suites:direct:py35:postCommitIT"
dependsOn ":sdks:python:test-suites:portable:py35:postCommitPy35"
}
task python36PostCommit() {
dependsOn ":sdks:python:test-suites:dataflow:py36:postCommitIT"
dependsOn ":sdks:python:test-suites:direct:py36:postCommitIT"
dependsOn ":sdks:python:test-suites:portable:py36:postCommitPy36"
}
task python37PostCommit() {
dependsOn ":sdks:python:test-suites:portable:py37:crossLanguagePythonJavaKafkaIOFlink"
dependsOn ":sdks:python:test-suites:dataflow:py37:postCommitIT"
dependsOn ":sdks:python:test-suites:direct:py37:postCommitIT"
dependsOn ":sdks:python:test-suites:direct:py37:hdfsIntegrationTest"
dependsOn ":sdks:python:test-suites:portable:py37:postCommitPy37"
}
task portablePythonPreCommit() {
dependsOn ":sdks:python:test-suites:portable:py2:preCommitPy2"
dependsOn ":sdks:python:test-suites:portable:py35:preCommitPy35"
dependsOn ":sdks:python:test-suites:portable:py36:preCommitPy36"
dependsOn ":sdks:python:test-suites:portable:py37:preCommitPy37"
}
task pythonSparkPostCommit() {
dependsOn ":sdks:python:test-suites:portable:py2:sparkValidatesRunner"
dependsOn ":sdks:python:test-suites:portable:py35:sparkValidatesRunner"
dependsOn ":sdks:python:test-suites:portable:py36:sparkValidatesRunner"
dependsOn ":sdks:python:test-suites:portable:py37:sparkValidatesRunner"
}
task websitePreCommit() {
dependsOn ":website:preCommit"
}
task communityMetricsPreCommit() {
dependsOn ":beam-test-infra-metrics:preCommit"
}
task communityMetricsProber() {
dependsOn ":beam-test-infra-metrics:checkProber"
}
task javaExamplesDataflowPrecommit() {
dependsOn ":runners:google-cloud-dataflow-java:examples:preCommit"
dependsOn ":runners:google-cloud-dataflow-java:examples-streaming:preCommit"
}
task runBeamDependencyCheck() {
dependsOn ":dependencyUpdates"
dependsOn ":sdks:python:dependencyUpdates"
}
// Configure the release plugin to do only local work; the release manager determines what, if
// anything, to push. On failure, the release manager can reset the branch without pushing.
release {
revertOnFail = false
tagTemplate = 'v${version}'
git {
requireBranch = 'release-.*|master'
pushToRemote = ''
}
}
// Reports linkage errors across multiple Apache Beam artifact ids.
//
// To use (from the root of project):
// ./gradlew -Ppublishing -PjavaLinkageArtifactIds=artifactId1,artifactId2,... :checkJavaLinkage
//
// For example:
// ./gradlew -Ppublishing -PjavaLinkageArtifactIds=beam-sdks-java-core,beam-sdks-java-io-jdbc :checkJavaLinkage
//
// Note that this task publishes artifacts into your local Maven repository.
if (project.hasProperty('javaLinkageArtifactIds')) {
if (!project.hasProperty('publishing')) {
throw new GradleException('You can only check linkage of Java artifacts if you specify -Ppublishing on the command line as well.')
}
configurations { linkageCheckerJava }
dependencies {
linkageCheckerJava "com.google.cloud.tools:dependencies:1.4.0"
}
// We need to evaluate all the projects first so that we can find depend on all the
// publishMavenJavaPublicationToMavenLocal tasks below.
for (p in rootProject.subprojects) {
if (!p.path.equals(project.path)) {
evaluationDependsOn(p.path)
}
}
project.task('checkJavaLinkage', type: JavaExec) {
dependsOn project.getTasksByName('publishMavenJavaPublicationToMavenLocal', true /* recursively */)
classpath = project.configurations.linkageCheckerJava
main = 'com.google.cloud.tools.opensource.classpath.LinkageCheckerMain'
def arguments = ['-a', project.javaLinkageArtifactIds.split(',').collect({
if (it.contains(':')) {
"${project.ext.mavenGroupId}:${it}"
} else {
// specify the version if not provided
"${project.ext.mavenGroupId}:${it}:${project.version}"
}
}).join(',')]
// Exclusion file filters out existing linkage errors before a change
if (project.hasProperty('javaLinkageWriteBaseline')) {
arguments += ['--output-exclusion-file', project.getProperty('javaLinkageWriteBaseline')]
} else if (project.hasProperty('javaLinkageReadBaseline')) {
arguments += ['--exclusion-file', project.getProperty('javaLinkageReadBaseline')]
}
args arguments
doLast {
println "NOTE: This task published artifacts into your local Maven repository. You may want to remove them manually."
}
}
}
if (project.hasProperty('compileAndRunTestsWithJava11')) {
project.javaPreCommitPortabilityApi.dependsOn ':sdks:java:testing:test-utils:verifyJavaVersion'
project.javaExamplesDataflowPrecommit.dependsOn ':sdks:java:testing:test-utils:verifyJavaVersion'
project.javaPreCommitBeamZetaSQL.dependsOn ':sdks:java:testing:test-utils:verifyJavaVersion'
project.sqlPreCommit.dependsOn ':sdks:java:testing:test-utils:verifyJavaVersion'
} else {
allprojects {
tasks.withType(Test) {
exclude '**/JvmVerification.class'
}
}
}