/
BeamModulePlugin.groovy
2439 lines (2198 loc) · 121 KB
/
BeamModulePlugin.groovy
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* 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.
*/
package org.apache.beam.gradle
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import org.gradle.api.attributes.Category
import org.gradle.api.GradleException
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileTree
import org.gradle.api.plugins.quality.Checkstyle
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.Exec
import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.testing.jacoco.tasks.JacocoReport
import java.util.concurrent.atomic.AtomicInteger
/**
* This plugin adds methods to configure a module with Beam's defaults, called "natures".
*
* <p>The natures available:
*
* <ul>
* <li>Java - Configures plugins commonly found in Java projects
* <li>Go - Configures plugins commonly found in Go projects
* <li>Docker - Configures plugins commonly used to build Docker containers
* <li>Grpc - Configures plugins commonly used to generate source from protos
* <li>Avro - Configures plugins commonly used to generate source from Avro specifications
* </ul>
*
* <p>For example, see applyJavaNature.
*/
class BeamModulePlugin implements Plugin<Project> {
/** Licence header enforced by spotless */
static final String javaLicenseHeader = """/*
* 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.
*/
"""
static AtomicInteger startingExpansionPortNumber = new AtomicInteger(18091)
/** A class defining the set of configurable properties accepted by applyJavaNature. */
class JavaNatureConfiguration {
/** Controls whether the spotbugs plugin is enabled and configured. */
boolean enableSpotbugs = true
/** Regexes matching generated classes which should not receive extended type checking. */
List<String> generatedClassPatterns = []
/** Classes triggering Checker failures. A map from class name to the bug filed against checkerframework. */
Map<String, String> classesTriggerCheckerBugs = [:]
/** Controls whether the dependency analysis plugin is enabled. */
boolean enableStrictDependencies = true
/** Override the default "beam-" + `dash separated path` archivesBaseName. */
String archivesBaseName = null
/**
* List of additional lint warnings to disable.
* In addition, defaultLintSuppressions defined below
* will be applied to all projects.
*/
List<String> disableLintWarnings = []
/** Controls whether tests are run with shadowJar. */
boolean testShadowJar = false
/**
* Controls whether the shadow jar is validated to not contain any classes outside the org.apache.beam namespace.
* This protects artifact jars from leaking dependencies classes causing conflicts for users.
*
* Note that this can be disabled for subprojects that produce application artifacts that are not intended to
* be depended on by users.
*/
boolean validateShadowJar = true
/**
* The set of excludes that should be used during validation of the shadow jar. Projects should override
* the default with the most specific set of excludes that is valid for the contents of its shaded jar.
*
* By default we exclude any class underneath the org.apache.beam namespace.
*/
List<String> shadowJarValidationExcludes = ["org/apache/beam/**"]
/**
* If unset, no shading is performed. The jar and test jar archives are used during publishing.
* Otherwise the shadowJar and shadowTestJar artifacts are used during publishing.
*
* The shadowJar / shadowTestJar tasks execute the specified closure to configure themselves.
*/
Closure shadowClosure
/** Controls whether this project is published to Maven. */
boolean publish = true
/** Controls whether javadoc is exported for this project. */
boolean exportJavadoc = true
/**
* Automatic-Module-Name Header value to be set in MANFIEST.MF file.
* This is a required parameter unless publishing to Maven is disabled for this project.
*
* @see: https://github.com/GoogleCloudPlatform/cloud-opensource-java/blob/master/library-best-practices/JLBP-20.md
*/
String automaticModuleName = null
/**
* The set of additional maven repositories that should be added into published POM file.
*/
List<Map> mavenRepositories = []
}
/** A class defining the set of configurable properties accepted by applyPortabilityNature. */
class PortabilityNatureConfiguration {
/**
* The set of excludes that should be used during validation of the shadow jar. Projects should override
* the default with the most specific set of excludes that is valid for the contents of its shaded jar.
*
* By default we exclude any class underneath the org.apache.beam namespace.
*/
List<String> shadowJarValidationExcludes = ["org/apache/beam/**"]
/** Override the default "beam-" + `dash separated path` archivesBaseName. */
String archivesBaseName = null
/** Controls whether this project is published to Maven. */
boolean publish = true
/**
* Regexes matching generated Java classes which should not receive extended type checking.
*
* By default, skips anything in the `org.apache.beam.model` namespace.
*/
List<String> generatedClassPatterns = [
"^org\\.apache\\.beam\\.model.*"
]
/**
* Automatic-Module-Name Header value to be set in MANFIEST.MF file.
* This is a required parameter unless publishing to Maven is disabled for this project.
*
* @see: https://github.com/GoogleCloudPlatform/cloud-opensource-java/blob/master/library-best-practices/JLBP-20.md
*/
String automaticModuleName
}
// A class defining the set of configurable properties for createJavaExamplesArchetypeValidationTask
class JavaExamplesArchetypeValidationConfiguration {
// Type [Quickstart, MobileGaming] for the postrelease validation is required.
// Used both for the test name run${type}Java${runner}
// and also for the script name, ${type}-java-${runner}.toLowerCase().
String type
// runner [Direct, Dataflow, Spark, Flink, FlinkLocal]
String runner
// gcpProject sets the gcpProject argument when executing examples.
String gcpProject
// gcpRegion sets the region for executing Dataflow examples.
String gcpRegion
// gcsBucket sets the gcsProject argument when executing examples.
String gcsBucket
// bqDataset sets the BigQuery Dataset when executing mobile-gaming examples
String bqDataset
// pubsubTopic sets topics when executing streaming pipelines
String pubsubTopic
}
// Reads and contains all necessary performance test parameters
class JavaPerformanceTestConfiguration {
// Optional. Runner which will be used for running the tests. Possible values: dataflow/direct.
// PerfKitBenchmarker will have trouble reading 'null' value. It expects empty string if no config file is expected.
String runner = System.getProperty('integrationTestRunner', '')
// Optional. Filesystem which will be used for running the tests. Possible values: hdfs.
// if not specified runner's local filesystem will be used.
String filesystem = System.getProperty('filesystem')
// Required. Pipeline options to be used by the tested pipeline.
String integrationTestPipelineOptions = System.getProperty('integrationTestPipelineOptions')
}
// Reads and contains all necessary performance test parameters
class PythonPerformanceTestConfiguration {
// Fully qualified name of the test to run.
String tests = System.getProperty('tests')
// Attribute tag that can filter the test set.
String attribute = System.getProperty('attr')
// Extra test options pass to nose.
String[] extraTestOptions = ["--nocapture"]
// Name of Cloud KMS encryption key to use in some tests.
String kmsKeyName = System.getProperty('kmsKeyName')
// Pipeline options to be used for pipeline invocation.
String pipelineOptions = System.getProperty('pipelineOptions', '')
}
// A class defining the set of configurable properties accepted by containerImageName.
class ContainerImageNameConfiguration {
String root = null // Sets the docker repository root (optional).
String name = null // Sets the short container image name, such as "go" (required).
String tag = null // Sets the image tag (optional).
}
// A class defining the configuration for PortableValidatesRunner.
class PortableValidatesRunnerConfiguration {
// Task name for validate runner case.
String name = 'validatesPortableRunner'
// Fully qualified JobServerClass name to use.
String jobServerDriver
// A string representing the jobServer Configuration.
String jobServerConfig
// Number of parallel test runs.
Integer numParallelTests = 1
// Extra options to pass to TestPipeline
String[] pipelineOpts = []
// Spin up the Harness inside a DOCKER container
Environment environment = Environment.DOCKER
// Categories for tests to run.
Closure testCategories = {
includeCategories 'org.apache.beam.sdk.testing.ValidatesRunner'
// Use the following to include / exclude categories:
// includeCategories 'org.apache.beam.sdk.testing.ValidatesRunner'
// excludeCategories 'org.apache.beam.sdk.testing.FlattenWithHeterogeneousCoders'
}
// Tests to include/exclude from running, by default all tests are included
Closure testFilter = {
// Use the following to include / exclude tests:
// includeTestsMatching 'org.apache.beam.sdk.transforms.FlattenTest.testFlattenWithDifferentInputAndOutputCoders2'
// excludeTestsMatching 'org.apache.beam.sdk.transforms.FlattenTest.testFlattenWithDifferentInputAndOutputCoders2'
}
// Configuration for the classpath when running the test.
Configuration testClasspathConfiguration
// Additional system properties.
Properties systemProperties = []
enum Environment {
DOCKER, // Docker-based Harness execution
PROCESS, // Process-based Harness execution
EMBEDDED, // Execute directly inside the execution engine (testing only)
}
}
// A class defining the configuration for CrossLanguageValidatesRunner.
class CrossLanguageValidatesRunnerConfiguration {
// Task name for cross-language validate runner case.
String name = 'validatesCrossLanguageRunner'
// Java pipeline options to use.
List<String> javaPipelineOptions = [
"--runner=PortableRunner",
"--jobEndpoint=localhost:8099",
"--environmentCacheMillis=10000",
"--experiments=beam_fn_api",
]
// Python pipeline options to use.
List<String> pythonPipelineOptions = [
"--runner=PortableRunner",
"--job_endpoint=localhost:8099",
"--environment_cache_millis=10000",
"--experiments=beam_fn_api",
]
// Additional nosetests options
List<String> nosetestsOptions = []
// Job server startup task.
Task startJobServer
// Job server cleanup task.
Task cleanupJobServer
// Number of parallel test runs.
Integer numParallelTests = 1
// Whether the pipeline needs --sdk_location option
boolean needsSdkLocation = false
// Categories for Java tests to run.
Closure javaTestCategories = {
includeCategories 'org.apache.beam.sdk.testing.UsesCrossLanguageTransforms'
// Use the following to include / exclude categories:
// includeCategories 'org.apache.beam.sdk.testing.ValidatesRunner'
// excludeCategories 'org.apache.beam.sdk.testing.FlattenWithHeterogeneousCoders'
}
// Attribute for Python tests to run.
String pythonTestAttr = "UsesCrossLanguageTransforms"
// classpath for running tests.
FileCollection classpath
}
def isRelease(Project project) {
return project.hasProperty('isRelease')
}
def defaultArchivesBaseName(Project p) {
return 'beam' + p.path.replace(':', '-')
}
void apply(Project project) {
/** ***********************************************************************************************/
// Apply common properties/repositories and tasks to all projects.
project.ext.mavenGroupId = 'org.apache.beam'
// Automatically use the official release version if we are performing a release
// otherwise append '-SNAPSHOT'
project.version = '2.31.0'
if (!isRelease(project)) {
project.version += '-SNAPSHOT'
}
// Default to dash-separated directories for artifact base name,
// which will also be the default artifactId for maven publications
project.apply plugin: 'base'
project.archivesBaseName = defaultArchivesBaseName(project)
project.apply plugin: 'org.apache.beam.jenkins'
// Register all Beam repositories and configuration tweaks
Repositories.register(project)
// Apply a plugin which enables configuring projects imported into Intellij.
project.apply plugin: "idea"
// Provide code coverage
// TODO: Should this only apply to Java projects?
project.apply plugin: "jacoco"
project.gradle.taskGraph.whenReady { graph ->
// Disable jacoco unless report requested such that task outputs can be properly cached.
// https://discuss.gradle.org/t/do-not-cache-if-condition-matched-jacoco-agent-configured-with-append-true-satisfied/23504
def enabled = graph.allTasks.any { it instanceof JacocoReport || it.name.contains("javaPreCommit") }
project.tasks.withType(Test) { jacoco.enabled = enabled }
}
// Apply a plugin which provides tasks for dependency / property / task reports.
// See https://docs.gradle.org/current/userguide/project_reports_plugin.html
// for further details. This is typically very useful to look at the "htmlDependencyReport"
// when attempting to resolve dependency issues.
project.apply plugin: "project-report"
// Apply a plugin which fails the build if there is a dependency on a transitive
// non-declared dependency, since these can break users (as in BEAM-6558)
//
// Though this is Java-specific, it is required to be applied to the root
// project due to implementation-details of the plugin. It can be enabled/disabled
// via JavaNatureConfiguration per project. It is disabled by default until we can
// make all of our deps good.
project.apply plugin: "ca.cutterslade.analyze"
// Adds a taskTree task that prints task dependency tree report to the console.
// Useful for investigating build issues.
// See: https://github.com/dorongold/gradle-task-tree
project.apply plugin: "com.dorongold.task-tree"
project.taskTree { noRepeat = true }
project.ext.allFlinkVersions = project.flink_versions.split(',')
project.ext.latestFlinkVersion = project.ext.allFlinkVersions.last()
/** ***********************************************************************************************/
// Define and export a map dependencies shared across multiple sub-projects.
//
// Example usage:
// configuration {
// compile library.java.avro
// testCompile library.java.junit
// }
// These versions are defined here because they represent
// a dependency version which should match across multiple
// Maven artifacts.
def activemq_version = "5.14.5"
def autovalue_version = "1.8.1"
def aws_java_sdk_version = "1.11.974"
def aws_java_sdk2_version = "2.15.31"
def cassandra_driver_version = "3.10.2"
def checkerframework_version = "3.10.0"
def classgraph_version = "4.8.104"
def errorprone_version = "2.3.4"
def google_clients_version = "1.31.0"
def google_cloud_bigdataoss_version = "2.1.6"
def google_cloud_pubsublite_version = "0.13.2"
def google_code_gson_version = "2.8.6"
def google_oauth_clients_version = "1.31.0"
// Try to keep grpc_version consistent with gRPC version in google_cloud_platform_libraries_bom
def grpc_version = "1.37.0"
def guava_version = "30.1-jre"
def hadoop_version = "2.10.1"
def hamcrest_version = "2.1"
def influxdb_version = "2.19"
def httpclient_version = "4.5.10"
def httpcore_version = "4.4.12"
def jackson_version = "2.12.1"
def jaxb_api_version = "2.3.3"
def jsr305_version = "3.0.2"
def kafka_version = "2.4.1"
def nemo_version = "0.1"
def netty_version = "4.1.52.Final"
def postgres_version = "42.2.16"
def powermock_version = "2.0.9"
// Try to keep protobuf_version consistent with the protobuf version in google_cloud_platform_libraries_bom
def protobuf_version = "3.15.8"
def quickcheck_version = "0.8"
def slf4j_version = "1.7.30"
def spark_version = "2.4.8"
def spotbugs_version = "4.0.6"
def testcontainers_version = "1.15.1"
// A map of maps containing common libraries used per language. To use:
// dependencies {
// compile library.java.slf4j_api
// }
project.ext.library = [
java : [
activemq_amqp : "org.apache.activemq:activemq-amqp:$activemq_version",
activemq_broker : "org.apache.activemq:activemq-broker:$activemq_version",
activemq_client : "org.apache.activemq:activemq-client:$activemq_version",
activemq_jaas : "org.apache.activemq:activemq-jaas:$activemq_version",
activemq_junit : "org.apache.activemq.tooling:activemq-junit:$activemq_version",
activemq_kahadb_store : "org.apache.activemq:activemq-kahadb-store:$activemq_version",
activemq_mqtt : "org.apache.activemq:activemq-mqtt:$activemq_version",
antlr : "org.antlr:antlr4:4.7",
antlr_runtime : "org.antlr:antlr4-runtime:4.7",
args4j : "args4j:args4j:2.33",
auto_value_annotations : "com.google.auto.value:auto-value-annotations:$autovalue_version",
avro : "org.apache.avro:avro:1.8.2",
avro_tests : "org.apache.avro:avro:1.8.2:tests",
aws_java_sdk_cloudwatch : "com.amazonaws:aws-java-sdk-cloudwatch:$aws_java_sdk_version",
aws_java_sdk_core : "com.amazonaws:aws-java-sdk-core:$aws_java_sdk_version",
aws_java_sdk_dynamodb : "com.amazonaws:aws-java-sdk-dynamodb:$aws_java_sdk_version",
aws_java_sdk_kinesis : "com.amazonaws:aws-java-sdk-kinesis:$aws_java_sdk_version",
aws_java_sdk_s3 : "com.amazonaws:aws-java-sdk-s3:$aws_java_sdk_version",
aws_java_sdk_sns : "com.amazonaws:aws-java-sdk-sns:$aws_java_sdk_version",
aws_java_sdk_sqs : "com.amazonaws:aws-java-sdk-sqs:$aws_java_sdk_version",
aws_java_sdk_sts : "com.amazonaws:aws-java-sdk-sts:$aws_java_sdk_version",
aws_java_sdk2_apache_client : "software.amazon.awssdk:apache-client:$aws_java_sdk2_version",
aws_java_sdk2_auth : "software.amazon.awssdk:auth:$aws_java_sdk2_version",
aws_java_sdk2_cloudwatch : "software.amazon.awssdk:cloudwatch:$aws_java_sdk2_version",
aws_java_sdk2_dynamodb : "software.amazon.awssdk:dynamodb:$aws_java_sdk2_version",
aws_java_sdk2_kinesis : "software.amazon.awssdk:kinesis:$aws_java_sdk2_version",
aws_java_sdk2_sdk_core : "software.amazon.awssdk:sdk-core:$aws_java_sdk2_version",
aws_java_sdk2_sns : "software.amazon.awssdk:sns:$aws_java_sdk2_version",
aws_java_sdk2_sqs : "software.amazon.awssdk:sqs:$aws_java_sdk2_version",
aws_java_sdk2_s3 : "software.amazon.awssdk:s3:$aws_java_sdk2_version",
aws_java_sdk2_http_client_spi : "software.amazon.awssdk:http-client-spi:$aws_java_sdk2_version",
aws_java_sdk2_regions : "software.amazon.awssdk:regions:$aws_java_sdk2_version",
aws_java_sdk2_utils : "software.amazon.awssdk:utils:$aws_java_sdk2_version",
bigdataoss_gcsio : "com.google.cloud.bigdataoss:gcsio:$google_cloud_bigdataoss_version",
bigdataoss_util : "com.google.cloud.bigdataoss:util:$google_cloud_bigdataoss_version",
cassandra_driver_core : "com.datastax.cassandra:cassandra-driver-core:$cassandra_driver_version",
cassandra_driver_mapping : "com.datastax.cassandra:cassandra-driver-mapping:$cassandra_driver_version",
classgraph : "io.github.classgraph:classgraph:$classgraph_version",
commons_codec : "commons-codec:commons-codec:1.14",
commons_compress : "org.apache.commons:commons-compress:1.20",
commons_csv : "org.apache.commons:commons-csv:1.8",
commons_io : "commons-io:commons-io:2.6",
commons_lang3 : "org.apache.commons:commons-lang3:3.9",
commons_math3 : "org.apache.commons:commons-math3:3.6.1",
error_prone_annotations : "com.google.errorprone:error_prone_annotations:$errorprone_version",
flogger_system_backend : "com.google.flogger:flogger-system-backend:0.6",
gax : "com.google.api:gax", // google_cloud_platform_libraries_bom sets version
gax_grpc : "com.google.api:gax-grpc", // google_cloud_platform_libraries_bom sets version
gax_httpjson : "com.google.api:gax-httpjson", // google_cloud_platform_libraries_bom sets version
google_api_client : "com.google.api-client:google-api-client:1.31.1", // 1.31.1 is required to run 1.31.0 of google_clients_version below.
google_api_client_jackson2 : "com.google.api-client:google-api-client-jackson2:$google_clients_version",
google_api_client_java6 : "com.google.api-client:google-api-client-java6:$google_clients_version",
google_api_common : "com.google.api:api-common", // google_cloud_platform_libraries_bom sets version
google_api_services_bigquery : "com.google.apis:google-api-services-bigquery:v2-rev20210410-$google_clients_version",
google_api_services_clouddebugger : "com.google.apis:google-api-services-clouddebugger:v2-rev20210326-$google_clients_version",
google_api_services_cloudresourcemanager : "com.google.apis:google-api-services-cloudresourcemanager:v1-rev20210331-$google_clients_version",
google_api_services_dataflow : "com.google.apis:google-api-services-dataflow:v1b3-rev20210408-$google_clients_version",
google_api_services_healthcare : "com.google.apis:google-api-services-healthcare:v1beta1-rev20210407-$google_clients_version",
google_api_services_pubsub : "com.google.apis:google-api-services-pubsub:v1-rev20210322-$google_clients_version",
google_api_services_storage : "com.google.apis:google-api-services-storage:v1-rev20210127-$google_clients_version",
google_auth_library_credentials : "com.google.auth:google-auth-library-credentials", // google_cloud_platform_libraries_bom sets version
google_auth_library_oauth2_http : "com.google.auth:google-auth-library-oauth2-http", // google_cloud_platform_libraries_bom sets version
google_cloud_bigquery : "com.google.cloud:google-cloud-bigquery", // google_cloud_platform_libraries_bom sets version
google_cloud_bigquery_storage : "com.google.cloud:google-cloud-bigquerystorage:1.21.1",
google_cloud_bigtable_client_core : "com.google.cloud.bigtable:bigtable-client-core:1.19.1",
google_cloud_bigtable_emulator : "com.google.cloud:google-cloud-bigtable-emulator:0.125.2",
google_cloud_core : "com.google.cloud:google-cloud-core", // google_cloud_platform_libraries_bom sets version
google_cloud_core_grpc : "com.google.cloud:google-cloud-core-grpc", // google_cloud_platform_libraries_bom sets version
google_cloud_datacatalog_v1beta1 : "com.google.cloud:google-cloud-datacatalog", // google_cloud_platform_libraries_bom sets version
google_cloud_dataflow_java_proto_library_all: "com.google.cloud.dataflow:google-cloud-dataflow-java-proto-library-all:0.5.160304",
google_cloud_datastore_v1_proto_client : "com.google.cloud.datastore:datastore-v1-proto-client:1.6.3",
google_cloud_pubsub : "com.google.cloud:google-cloud-pubsub", // google_cloud_platform_libraries_bom sets version
google_cloud_pubsublite : "com.google.cloud:google-cloud-pubsublite:$google_cloud_pubsublite_version",
// The GCP Libraries BOM dashboard shows the versions set by the BOM:
// https://storage.googleapis.com/cloud-opensource-java-dashboard/com.google.cloud/libraries-bom/20.0.0/artifact_details.html
// Update libraries-bom version on sdks/java/container/license_scripts/dep_urls_java.yaml
google_cloud_platform_libraries_bom : "com.google.cloud:libraries-bom:20.0.0",
google_cloud_spanner : "com.google.cloud:google-cloud-spanner", // google_cloud_platform_libraries_bom sets version
google_code_gson : "com.google.code.gson:gson:$google_code_gson_version",
// google-http-client's version is explicitly declared for sdks/java/maven-archetypes/examples
// This version should be in line with the one in com.google.cloud:libraries-bom.
google_http_client : "com.google.http-client:google-http-client", // google_cloud_platform_libraries_bom sets version
google_http_client_apache_v2 : "com.google.http-client:google-http-client-apache-v2", // google_cloud_platform_libraries_bom sets version
google_http_client_jackson : "com.google.http-client:google-http-client-jackson:1.29.2",
google_http_client_jackson2 : "com.google.http-client:google-http-client-jackson2", // google_cloud_platform_libraries_bom sets version
google_http_client_protobuf : "com.google.http-client:google-http-client-protobuf", // google_cloud_platform_libraries_bom sets version
google_oauth_client : "com.google.oauth-client:google-oauth-client:$google_oauth_clients_version",
google_oauth_client_java6 : "com.google.oauth-client:google-oauth-client-java6:$google_oauth_clients_version",
// Don't use grpc_all, it can cause issues in Bazel builds. Reference the gRPC libraries you need individually instead.
grpc_alts : "io.grpc:grpc-alts", // google_cloud_platform_libraries_bom sets version
grpc_api : "io.grpc:grpc-api", // google_cloud_platform_libraries_bom sets version
grpc_auth : "io.grpc:grpc-auth", // google_cloud_platform_libraries_bom sets version
grpc_context : "io.grpc:grpc-context", // google_cloud_platform_libraries_bom sets version
grpc_core : "io.grpc:grpc-core", // google_cloud_platform_libraries_bom sets version
grpc_google_cloud_pubsub_v1 : "com.google.api.grpc:grpc-google-cloud-pubsub-v1", // google_cloud_platform_libraries_bom sets version
grpc_google_cloud_pubsublite_v1 : "com.google.api.grpc:grpc-google-cloud-pubsublite-v1:$google_cloud_pubsublite_version",
grpc_google_common_protos : "com.google.api.grpc:grpc-google-common-protos", // google_cloud_platform_libraries_bom sets version
grpc_grpclb : "io.grpc:grpc-grpclb", // google_cloud_platform_libraries_bom sets version
grpc_protobuf : "io.grpc:grpc-protobuf", // google_cloud_platform_libraries_bom sets version
grpc_protobuf_lite : "io.grpc:grpc-protobuf-lite:$grpc_version",
grpc_netty : "io.grpc:grpc-netty", // google_cloud_platform_libraries_bom sets version
grpc_netty_shaded : "io.grpc:grpc-netty-shaded", // google_cloud_platform_libraries_bom sets version
grpc_stub : "io.grpc:grpc-stub", // google_cloud_platform_libraries_bom sets version
guava : "com.google.guava:guava:$guava_version",
guava_testlib : "com.google.guava:guava-testlib:$guava_version",
hadoop_client : "org.apache.hadoop:hadoop-client:$hadoop_version",
hadoop_common : "org.apache.hadoop:hadoop-common:$hadoop_version",
hadoop_mapreduce_client_core : "org.apache.hadoop:hadoop-mapreduce-client-core:$hadoop_version",
hadoop_minicluster : "org.apache.hadoop:hadoop-minicluster:$hadoop_version",
hadoop_hdfs : "org.apache.hadoop:hadoop-hdfs:$hadoop_version",
hadoop_hdfs_tests : "org.apache.hadoop:hadoop-hdfs:$hadoop_version:tests",
hamcrest : "org.hamcrest:hamcrest:$hamcrest_version",
hamcrest_core : "org.hamcrest:hamcrest-core:$hamcrest_version",
hamcrest_library : "org.hamcrest:hamcrest-library:$hamcrest_version",
http_client : "org.apache.httpcomponents:httpclient:$httpclient_version",
http_core : "org.apache.httpcomponents:httpcore:$httpcore_version",
influxdb_library : "org.influxdb:influxdb-java:$influxdb_version",
jackson_annotations : "com.fasterxml.jackson.core:jackson-annotations:$jackson_version",
jackson_jaxb_annotations : "com.fasterxml.jackson.module:jackson-module-jaxb-annotations:$jackson_version",
jackson_core : "com.fasterxml.jackson.core:jackson-core:$jackson_version",
jackson_databind : "com.fasterxml.jackson.core:jackson-databind:$jackson_version",
jackson_dataformat_cbor : "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:$jackson_version",
jackson_dataformat_csv : "com.fasterxml.jackson.dataformat:jackson-dataformat-csv:$jackson_version",
jackson_dataformat_xml : "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version",
jackson_dataformat_yaml : "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:$jackson_version",
jackson_datatype_joda : "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version",
jackson_module_scala_2_11 : "com.fasterxml.jackson.module:jackson-module-scala_2.11:$jackson_version",
jackson_module_scala_2_12 : "com.fasterxml.jackson.module:jackson-module-scala_2.12:$jackson_version",
jaxb_api : "jakarta.xml.bind:jakarta.xml.bind-api:$jaxb_api_version",
jaxb_impl : "com.sun.xml.bind:jaxb-impl:$jaxb_api_version",
joda_time : "joda-time:joda-time:2.10.10",
jsonassert : "org.skyscreamer:jsonassert:1.5.0",
jsr305 : "com.google.code.findbugs:jsr305:$jsr305_version",
junit : "junit:junit:4.13.1",
kafka : "org.apache.kafka:kafka_2.11:$kafka_version",
kafka_clients : "org.apache.kafka:kafka-clients:$kafka_version",
mockito_core : "org.mockito:mockito-core:3.7.7",
mongo_java_driver : "org.mongodb:mongo-java-driver:3.12.7",
nemo_compiler_frontend_beam : "org.apache.nemo:nemo-compiler-frontend-beam:$nemo_version",
netty_all : "io.netty:netty-all:$netty_version",
netty_handler : "io.netty:netty-handler:$netty_version",
netty_tcnative_boringssl_static : "io.netty:netty-tcnative-boringssl-static:2.0.33.Final",
netty_transport_native_epoll : "io.netty:netty-transport-native-epoll:$netty_version",
postgres : "org.postgresql:postgresql:$postgres_version",
powermock : "org.powermock:powermock-module-junit4:$powermock_version",
powermock_mockito : "org.powermock:powermock-api-mockito2:$powermock_version",
protobuf_java : "com.google.protobuf:protobuf-java:$protobuf_version",
protobuf_java_util : "com.google.protobuf:protobuf-java-util:$protobuf_version",
proto_google_cloud_bigquery_storage_v1 : "com.google.api.grpc:proto-google-cloud-bigquerystorage-v1", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_bigtable_admin_v2 : "com.google.api.grpc:proto-google-cloud-bigtable-admin-v2", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_bigquery_storage_v1beta2 : "com.google.api.grpc:proto-google-cloud-bigquerystorage-v1beta2", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_bigtable_v2 : "com.google.api.grpc:proto-google-cloud-bigtable-v2", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_datacatalog_v1beta1 : "com.google.api.grpc:proto-google-cloud-datacatalog-v1beta1", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_datastore_v1 : "com.google.api.grpc:proto-google-cloud-datastore-v1", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_pubsub_v1 : "com.google.api.grpc:proto-google-cloud-pubsub-v1", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_pubsublite_v1 : "com.google.api.grpc:proto-google-cloud-pubsublite-v1:$google_cloud_pubsublite_version",
proto_google_cloud_spanner_v1: "com.google.api.grpc:proto-google-cloud-spanner-v1", // google_cloud_platform_libraries_bom sets version
proto_google_cloud_spanner_admin_database_v1: "com.google.api.grpc:proto-google-cloud-spanner-admin-database-v1", // google_cloud_platform_libraries_bom sets version
proto_google_common_protos : "com.google.api.grpc:proto-google-common-protos", // google_cloud_platform_libraries_bom sets version
slf4j_api : "org.slf4j:slf4j-api:$slf4j_version",
slf4j_simple : "org.slf4j:slf4j-simple:$slf4j_version",
slf4j_jdk14 : "org.slf4j:slf4j-jdk14:$slf4j_version",
slf4j_log4j12 : "org.slf4j:slf4j-log4j12:$slf4j_version",
snappy_java : "org.xerial.snappy:snappy-java:1.1.8.4",
spark_core : "org.apache.spark:spark-core_2.11:$spark_version",
spark_network_common : "org.apache.spark:spark-network-common_2.11:$spark_version",
spark_sql : "org.apache.spark:spark-sql_2.11:$spark_version",
spark_streaming : "org.apache.spark:spark-streaming_2.11:$spark_version",
stax2_api : "org.codehaus.woodstox:stax2-api:4.2.1",
testcontainers_clickhouse : "org.testcontainers:clickhouse:$testcontainers_version",
testcontainers_elasticsearch : "org.testcontainers:elasticsearch:$testcontainers_version",
testcontainers_kafka : "org.testcontainers:kafka:$testcontainers_version",
testcontainers_localstack : "org.testcontainers:localstack:$testcontainers_version",
testcontainers_postgresql : "org.testcontainers:postgresql:$testcontainers_version",
testcontainers_gcloud : "org.testcontainers:gcloud:$testcontainers_version",
vendored_bytebuddy_1_11_0 : "org.apache.beam:beam-vendor-bytebuddy-1_11_0:0.1",
vendored_grpc_1_36_0 : "org.apache.beam:beam-vendor-grpc-1_36_0:0.1",
vendored_guava_26_0_jre : "org.apache.beam:beam-vendor-guava-26_0-jre:0.1",
vendored_calcite_1_20_0 : "org.apache.beam:beam-vendor-calcite-1_20_0:0.1",
woodstox_core_asl : "org.codehaus.woodstox:woodstox-core-asl:4.4.1",
zstd_jni : "com.github.luben:zstd-jni:1.4.5-2",
quickcheck_core : "com.pholser:junit-quickcheck-core:$quickcheck_version",
],
groovy: [
groovy_all: "org.codehaus.groovy:groovy-all:2.4.13",
],
// For generating pom.xml from archetypes.
maven: [
maven_compiler_plugin: "maven-plugins:maven-compiler-plugin:3.7.0",
maven_exec_plugin : "maven-plugins:maven-exec-plugin:1.6.0",
maven_jar_plugin : "maven-plugins:maven-jar-plugin:3.0.2",
maven_shade_plugin : "maven-plugins:maven-shade-plugin:3.1.0",
maven_surefire_plugin: "maven-plugins:maven-surefire-plugin:3.0.0-M5",
],
]
/** ***********************************************************************************************/
// Returns a string representing the relocated path to be used with the shadow plugin when
// given a suffix such as "com.google.common".
project.ext.getJavaRelocatedPath = { String suffix ->
return ("org.apache.beam.repackaged."
+ project.name.replace("-", "_")
+ "."
+ suffix)
}
project.ext.repositories = {
maven {
name "testPublicationLocal"
url "file://${project.rootProject.projectDir}/testPublication/"
}
maven {
url(project.properties['distMgmtSnapshotsUrl'] ?: isRelease(project)
? 'https://repository.apache.org/service/local/staging/deploy/maven2'
: 'https://repository.apache.org/content/repositories/snapshots')
name(project.properties['distMgmtServerId'] ?: isRelease(project)
? 'apache.releases.https' : 'apache.snapshots.https')
// The maven settings plugin will load credentials from ~/.m2/settings.xml file that a user
// has configured with the Apache release and snapshot staging credentials.
// <settings>
// <servers>
// <server>
// <id>apache.releases.https</id>
// <username>USER_TOKEN</username>
// <password>PASS_TOKEN</password>
// </server>
// <server>
// <id>apache.snapshots.https</id>
// <username>USER_TOKEN</username>
// <password>PASS_TOKEN</password>
// </server>
// </servers>
// </settings>
}
}
// Configures a project with a default set of plugins that should apply to all Java projects.
//
// Users should invoke this method using Groovy map syntax. For example:
// applyJavaNature(enableSpotbugs: true)
//
// See JavaNatureConfiguration for the set of accepted properties.
//
// The following plugins are enabled:
// * java
// * maven
// * net.ltgt.apt (plugin to configure annotation processing tool)
// * propdeps (provide optional and provided dependency configurations)
// * propdeps-maven
// * propdeps-idea
// * checkstyle
// * spotbugs
// * shadow (conditional on shadowClosure being specified)
// * com.diffplug.spotless (code style plugin)
//
// Dependency Management for Java Projects
// ---------------------------------------
//
// By default, the shadow plugin is not enabled. It is only enabled by specifying a shadowClosure
// as an argument. If no shadowClosure has been specified, dependencies should fall into the
// configurations as described within the Gradle documentation (https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_plugin_and_dependency_management)
//
// When the shadowClosure argument is specified, the shadow plugin is enabled to perform shading
// of commonly found dependencies. Because of this it is important that dependencies are added
// to the correct configuration. Dependencies should fall into one of these four configurations:
// * compile - Required during compilation or runtime of the main source set.
// This configuration represents all dependencies that much also be shaded away
// otherwise the generated Maven pom will be missing this dependency.
// * shadow - Required during compilation or runtime of the main source set.
// Will become a runtime dependency of the generated Maven pom.
// * testCompile - Required during compilation or runtime of the test source set.
// This must be shaded away in the shaded test jar.
// * shadowTest - Required during compilation or runtime of the test source set.
// TODO: Figure out whether this should be a test scope dependency
// of the generated Maven pom.
//
// When creating a cross-project dependency between two Java projects, one should only rely on
// the shaded configurations if the project has a shadowClosure being specified. This allows
// for compilation/test execution to occur against the final artifact that will be provided to
// users. This is by done by referencing the "shadow" or "shadowTest" configuration as so:
// dependencies {
// shadow project(path: "other:java:project1", configuration: "shadow")
// shadowTest project(path: "other:java:project2", configuration: "shadowTest")
// }
// This will ensure the correct set of transitive dependencies from those projects are correctly
// added to the main and test source set runtimes.
project.ext.applyJavaNature = {
// Use the implicit it parameter of the closure to handle zero argument or one argument map calls.
JavaNatureConfiguration configuration = it ? it as JavaNatureConfiguration : new JavaNatureConfiguration()
if (configuration.archivesBaseName) {
project.archivesBaseName = configuration.archivesBaseName
}
project.apply plugin: "java"
// Configure the Java compiler source language and target compatibility levels. Also ensure that
// we configure the Java compiler to use UTF-8.
project.sourceCompatibility = project.javaVersion
project.targetCompatibility = project.javaVersion
def defaultLintSuppressions = [
'options',
'cast',
// https://bugs.openjdk.java.net/browse/JDK-8190452
'classfile',
'deprecation',
'fallthrough',
'processing',
'serial',
'try',
'unchecked',
'varargs',
]
project.tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
// As we want to add '-Xlint:-deprecation' we intentionally remove '-Xlint:deprecation' from compilerArgs here,
// as intellij is adding this, see https://youtrack.jetbrains.com/issue/IDEA-196615
options.compilerArgs -= [
"-Xlint:deprecation",
]
options.compilerArgs += ([
'-parameters',
'-Xlint:all',
'-Werror'
]
+ (defaultLintSuppressions + configuration.disableLintWarnings).collect { "-Xlint:-${it}" })
}
project.tasks.withType(Jar).configureEach {
preserveFileTimestamps(false)
}
if (project.hasProperty("compileAndRunTestsWithJava11")) {
def java11Home = project.findProperty("java11Home")
project.tasks.compileTestJava {
options.fork = true
options.forkOptions.javaHome = java11Home as File
options.compilerArgs += ['-Xlint:-path']
options.compilerArgs.addAll(['--release', '11'])
}
project.tasks.withType(Test) {
useJUnit()
executable = "${java11Home}/bin/java"
}
}
// Configure the default test tasks set of tests executed
// to match the equivalent set that is executed by the maven-surefire-plugin.
// See http://maven.apache.org/components/surefire/maven-surefire-plugin/test-mojo.html
project.test {
include "**/Test*.class"
include "**/*Test.class"
include "**/*Tests.class"
include "**/*TestCase.class"
// fixes issues with test filtering on multi-module project
// see https://discuss.gradle.org/t/multi-module-build-fails-with-tests-filter/25835
filter { setFailOnNoMatchingTests(false) }
}
project.tasks.withType(Test).configureEach {
// Configure all test tasks to use JUnit
useJUnit {}
// default maxHeapSize on gradle 5 is 512m, lets increase to handle more demanding tests
maxHeapSize = '2g'
}
List<String> skipDefRegexes = []
skipDefRegexes << "AutoValue_.*"
skipDefRegexes << "AutoOneOf_.*"
skipDefRegexes += configuration.generatedClassPatterns
skipDefRegexes += configuration.classesTriggerCheckerBugs.keySet()
String skipDefCombinedRegex = skipDefRegexes.collect({ regex -> "(${regex})"}).join("|")
// SLF4J logger handles null log message parameters
String skipUsesRegex = "^org\\.slf4j\\.Logger.*"
project.apply plugin: 'org.checkerframework'
project.checkerFramework {
checkers = [
'org.checkerframework.checker.nullness.NullnessChecker'
]
if (project.findProperty('enableCheckerFramework') || project.jenkins.isCIBuild) {
skipCheckerFramework = false
} else {
skipCheckerFramework = true
}
// Always exclude checkerframework on tests. It's slow, and it often
// raises erroneous error because we don't have checker annotations for
// test libraries like junit and hamcrest. See BEAM-11436.
// Consider re-enabling if we can get annotations for the test libraries
// we use.
excludeTests = true
extraJavacArgs = [
"-AskipDefs=${skipDefCombinedRegex}",
"-AskipUses=${skipUsesRegex}",
"-AsuppressWarnings=annotation.not.completed",
]
project.dependencies {
checkerFramework("org.checkerframework:checker:$checkerframework_version")
}
project.configurations.all {
it.exclude(group:"org.checkerframework", module:"jdk8")
}
}
if (configuration.shadowClosure) {
// Ensure that tests are packaged and part of the artifact set.
project.task('packageTests', type: Jar) {
classifier = 'tests-unshaded'
from project.sourceSets.test.output
}
project.artifacts.archives project.packageTests
}
// Configures annotation processing for commonly used annotation processors
// across all Java projects.
project.apply plugin: "net.ltgt.apt"
// let idea apt plugin handle the ide integration
project.apply plugin: "net.ltgt.apt-idea"
// Note that these plugins specifically use the compileOnly and testCompileOnly
// configurations because they are never required to be shaded or become a
// dependency of the output.
def compileOnlyAnnotationDeps = [
"com.google.auto.service:auto-service-annotations:1.0-rc6",
"com.google.auto.value:auto-value-annotations:$autovalue_version",
"com.google.code.findbugs:jsr305:$jsr305_version",
"com.google.j2objc:j2objc-annotations:1.3",
// These dependencies are needed to avoid error-prone warnings on package-info.java files,
// also to include the annotations to suppress warnings.
//
// spotbugs-annotations artifact is licensed under LGPL and cannot be included in the
// Apache Beam distribution, but may be relied on during build.
// See: https://www.apache.org/legal/resolved.html#prohibited
// Special case for jsr305 (a transitive dependency of spotbugs-annotations):
// sdks/java/core's FieldValueTypeInformation needs javax.annotations.Nullable at runtime.
// Therefore, the java core module declares jsr305 dependency (BSD license) as "compile".
// https://github.com/findbugsproject/findbugs/blob/master/findbugs/licenses/LICENSE-jsr305.txt
"com.github.spotbugs:spotbugs-annotations:$spotbugs_version",
"net.jcip:jcip-annotations:1.0",
// This explicitly adds javax.annotation.Generated (SOURCE retention)
// as a compile time dependency since Java 9+ no longer includes common
// EE annotations: http://bugs.openjdk.java.net/browse/JDK-8152842. This
// is required for grpc: http://github.com/grpc/grpc-java/issues/5343.
//
// javax.annotation is licensed under GPL 2.0 with Classpath Exception
// and must not be included in the Apache Beam distribution, but may be
// relied on during build.
// See exception in: https://www.apache.org/legal/resolved.html#prohibited
// License: https://github.com/javaee/javax.annotation/blob/1.3.2/LICENSE
"javax.annotation:javax.annotation-api:1.3.2",
]
project.dependencies {
compileOnlyAnnotationDeps.each { dep ->
compileOnly dep
testCompileOnly dep
annotationProcessor dep
testAnnotationProcessor dep
}
// Add common annotation processors to all Java projects
def annotationProcessorDeps = [
"com.google.auto.value:auto-value:$autovalue_version",
"com.google.auto.service:auto-service:1.0-rc6",
]
annotationProcessorDeps.each { dep ->
annotationProcessor dep
testAnnotationProcessor dep
}
// This contains many improved annotations beyond javax.annotations for enhanced static checking
// of the codebase. It is runtime so users can also take advantage of them. The annotations themselves
// are MIT licensed (checkerframework is GPL and cannot be distributed)
compile "org.checkerframework:checker-qual:$checkerframework_version"
}
// Add the optional and provided configurations for dependencies
// TODO: Either remove these plugins and find another way to generate the Maven poms
// with the correct dependency scopes configured.
project.apply plugin: 'propdeps'
project.apply plugin: 'propdeps-maven'
project.apply plugin: 'propdeps-idea'
// Defines Targets for sonarqube analysis reporting.
project.apply plugin: "org.sonarqube"
// Configures a checkstyle plugin enforcing a set of rules and also allows for a set of
// suppressions.
project.apply plugin: 'checkstyle'
project.tasks.withType(Checkstyle) {
configFile = project.project(":").file("sdks/java/build-tools/src/main/resources/beam/checkstyle.xml")
configProperties = ["checkstyle.suppressions.file": project.project(":").file("sdks/java/build-tools/src/main/resources/beam/suppressions.xml")]
showViolations = true
maxErrors = 0
}
project.checkstyle { toolVersion = "8.23" }
// Configures javadoc plugin and ensure check runs javadoc.
project.tasks.withType(Javadoc) {
options.encoding = 'UTF-8'
options.addBooleanOption('Xdoclint:-missing', true)
}
project.check.dependsOn project.javadoc
// Apply the eclipse and apt-eclipse plugins. This adds the "eclipse" task and
// connects the apt-eclipse plugin to update the eclipse project files
// with the instructions needed to run apt within eclipse to handle the AutoValue
// and additional annotations
project.apply plugin: 'eclipse'
project.apply plugin: "net.ltgt.apt-eclipse"
// Enables a plugin which can apply code formatting to source.
project.apply plugin: "com.diffplug.spotless"
// scan CVE
project.apply plugin: "net.ossindex.audit"
project.audit { rateLimitAsError = false }
// Spotless can be removed from the 'check' task by passing -PdisableSpotlessCheck=true on the Gradle
// command-line. This is useful for pre-commit which runs spotless separately.
def disableSpotlessCheck = project.hasProperty('disableSpotlessCheck') &&
project.disableSpotlessCheck == 'true'
project.spotless {
enforceCheck !disableSpotlessCheck
java {
licenseHeader javaLicenseHeader
googleJavaFormat('1.7')
target project.fileTree(project.projectDir) { include 'src/*/java/**/*.java' }
}
}