forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
281 lines (254 loc) · 11.7 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
/*
* 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.
*/
import groovy.json.JsonOutput
import java.util.stream.Collectors
plugins {
id 'org.apache.beam.module'
id 'org.javacc.javacc'
}
applyJavaNature(
generatedClassPatterns: [
/^org\.apache\.beam\.sdk\.extensions\.sql\.impl\.parser\.impl.*/,
],
automaticModuleName: 'org.apache.beam.sdk.extensions.sql',
classesTriggerCheckerBugs: [
// TODO(https://github.com/apache/beam/issues/21068): This currently crashes with checkerframework 3.10.0
// when compiling :sdks:java:extensions:sql:compileJava with:
// message: class file for com.google.datastore.v1.Entity not found
// ; The Checker Framework crashed. Please report the crash.
// Compilation unit: /usr/local/google/home/lcwik/git/beam/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/datastore/DataStoreV1TableProvider.java
// Last visited tree at line 49 column 1:
// @AutoService(TableProvider.class)
// Exception: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.google.datastore.v1.Entity not found; com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.google.datastore.v1.Entity not found
'DataStoreV1TableProvider': 'TODO(https://github.com/apache/beam/issues/21068): Report the crash if still occurring on newest version',
],
// javacc generated code produces lint warnings
disableLintWarnings: ['dep-ann', 'rawtypes'],
)
description = "Apache Beam :: SDKs :: Java :: Extensions :: SQL"
ext.summary = "Beam SQL provides a new interface to generate a Beam pipeline from SQL statement"
configurations {
// Create an fmppTask configuration representing the dependencies
// required to define and execute the Ant FMPP task.
// TODO: Migrate to a FMPP plugin once one exists
fmppTask
fmppTemplates
}
def hadoopVersions = [
"285": "2.8.5",
"292": "2.9.2",
"2102": "2.10.2",
"324": "3.2.4",
]
hadoopVersions.each {kv -> configurations.create("hadoopVersion$kv.key")}
dependencies {
implementation enforcedPlatform(library.java.google_cloud_platform_libraries_bom)
// TODO(https://github.com/apache/beam/issues/21156): Determine how to build without this dependency
provided "org.immutables:value:2.8.8"
permitUnusedDeclared "org.immutables:value:2.8.8"
javacc "net.java.dev.javacc:javacc:4.0"
fmppTask "com.googlecode.fmpp-maven-plugin:fmpp-maven-plugin:1.0"
fmppTask "org.freemarker:freemarker:2.3.31"
fmppTemplates library.java.vendored_calcite_1_28_0
implementation project(path: ":sdks:java:core", configuration: "shadow")
implementation project(":sdks:java:extensions:avro")
implementation project(":sdks:java:extensions:join-library")
permitUnusedDeclared project(":sdks:java:extensions:join-library") // BEAM-11761
implementation project(":sdks:java:extensions:sql:udf")
implementation project(path: ":runners:direct-java", configuration: "shadow")
implementation library.java.commons_codec
implementation library.java.commons_csv
implementation library.java.jackson_databind
implementation library.java.joda_time
implementation library.java.vendored_calcite_1_28_0
implementation "org.codehaus.janino:janino:3.0.11"
implementation "org.codehaus.janino:commons-compiler:3.0.11"
implementation library.java.jackson_core
implementation library.java.mongo_java_driver
implementation library.java.slf4j_api
implementation library.java.joda_time
implementation library.java.vendored_guava_32_1_2_jre
provided project(":sdks:java:io:kafka")
implementation project(":sdks:java:extensions:google-cloud-platform-core")
permitUnusedDeclared project(":sdks:java:extensions:google-cloud-platform-core")
implementation project(":sdks:java:io:google-cloud-platform")
implementation library.java.proto_google_cloud_bigtable_v2
implementation library.java.google_api_services_bigquery
permitUnusedDeclared library.java.google_api_services_bigquery
implementation library.java.proto_google_cloud_pubsublite_v1
implementation library.java.google_cloud_pubsublite
implementation project(":sdks:java:io:mongodb")
implementation library.java.avro
implementation library.java.protobuf_java
implementation library.java.protobuf_java_util
provided project(":sdks:java:io:parquet")
provided library.java.jackson_dataformat_xml
permitUnusedDeclared library.java.jackson_dataformat_xml
provided library.java.hadoop_client
permitUnusedDeclared library.java.hadoop_client
provided library.java.kafka_clients
testImplementation library.java.vendored_calcite_1_28_0
testImplementation library.java.vendored_guava_32_1_2_jre
testImplementation library.java.junit
testImplementation library.java.quickcheck_core
testImplementation library.java.testcontainers_kafka
testImplementation library.java.google_cloud_bigtable
testImplementation library.java.google_cloud_bigtable_client_core_config
testImplementation library.java.google_cloud_bigtable_emulator
testImplementation library.java.proto_google_cloud_bigtable_admin_v2
testImplementation library.java.proto_google_cloud_datastore_v1
testImplementation library.java.google_cloud_datastore_v1_proto_client
testImplementation library.java.kafka_clients
testImplementation project(":sdks:java:io:kafka")
testImplementation project(path: ":sdks:java:io:mongodb", configuration: "testRuntimeMigration")
testImplementation project(path: ":sdks:java:io:thrift", configuration: "testRuntimeMigration")
testImplementation project(path: ":sdks:java:extensions:protobuf", configuration: "testRuntimeMigration")
testCompileOnly project(":sdks:java:extensions:sql:udf-test-provider")
testRuntimeOnly library.java.slf4j_jdk14
hadoopVersions.each {kv ->
"hadoopVersion$kv.key" "org.apache.hadoop:hadoop-client:$kv.value"
}
}
hadoopVersions.each {kv ->
configurations."hadoopVersion$kv.key" {
resolutionStrategy {
force "org.apache.hadoop:hadoop-client:$kv.value"
}
}
}
// Copy Calcite templates and our own template into the build directory
// so we have one location for the FMPP task to parse.
task copyFmppTemplatesFromSrc(type: Copy) {
from "src/main/codegen"
into "${project.buildDir}/templates-fmpp/codegen"
}
task copyFmppTemplatesFromCalciteCore(type: Copy) {
dependsOn configurations.fmppTemplates
File calciteCoreJar = files(configurations.fmppTemplates.files).filter {
it.name.startsWith("beam-vendor-calcite")
}.singleFile
from zipTree(calciteCoreJar)
include "**/Parser.jj"
into "${project.buildDir}/templates-fmpp"
filter{
line ->
line.replace('import org.apache.calcite.', 'import org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.')
}
filter{
line ->
line.replace('import static org.apache.calcite.', 'import static org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.')
}
}
// Generate the FMPP sources from the FMPP templates.
def generateFmppOutputDir = "${project.buildDir}/generated/fmpp"
task generateFmppSources {
dependsOn configurations.fmppTask
dependsOn copyFmppTemplatesFromSrc
dependsOn copyFmppTemplatesFromCalciteCore
doLast {
ant.taskdef(name: "fmpp", classname: "fmpp.tools.AntTask", classpath: configurations.fmppTask.asPath)
ant.fmpp(configuration: "src/main/codegen/config.fmpp", sourceRoot: "${project.buildDir}/templates-fmpp/codegen/templates", outputRoot: generateFmppOutputDir)
}
}
// Match the output directory for generated code with the package, to be more tool-friendly
def generateFmppJavaccRoot = "${generateFmppOutputDir}/javacc"
def generatedJavaccSourceDir = "${project.buildDir}/generated/javacc"
def generatedJavaccPackageDir = "${generatedJavaccSourceDir}/org/apache/beam/sdk/extensions/sql/impl/parser/impl"
compileJavacc {
dependsOn generateFmppSources
inputDirectory = file(generateFmppJavaccRoot)
outputDirectory = file(generatedJavaccPackageDir)
arguments = [static: "false", lookahead: "2"]
}
// Help IntelliJ find the fmpp bits
idea {
module {
sourceDirs += file(generateFmppOutputDir)
generatedSourceDirs += file(generateFmppOutputDir)
sourceDirs += file(generatedJavaccSourceDir)
generatedSourceDirs += file(generatedJavaccSourceDir)
}
}
// Run basic SQL example
task runBasicExample(type: JavaExec) {
description = "Run basic SQL example"
mainClass = "org.apache.beam.sdk.extensions.sql.example.BeamSqlExample"
classpath = sourceSets.main.runtimeClasspath
args = ["--runner=DirectRunner"]
}
// Run SQL example on POJO inputs
task runPojoExample(type: JavaExec) {
description = "Run SQL example for PCollections of POJOs"
mainClass = "org.apache.beam.sdk.extensions.sql.example.BeamSqlPojoExample"
classpath = sourceSets.main.runtimeClasspath
args = ["--runner=DirectRunner"]
}
task integrationTest(type: Test) {
def gcpProject = project.findProperty('gcpProject') ?: 'apache-beam-testing'
def gcsTempRoot = project.findProperty('gcsTempRoot') ?: 'gs://temp-storage-for-end-to-end-tests/'
// Disable Gradle cache (it should not be used because the IT's won't run).
outputs.upToDateWhen { false }
def pipelineOptions = [
"--project=${gcpProject}",
"--tempLocation=${gcsTempRoot}",
"--blockOnRun=false"]
systemProperty "beamTestPipelineOptions", JsonOutput.toJson(pipelineOptions)
include '**/*IT.class'
maxParallelForks 4
classpath = project(":sdks:java:extensions:sql")
.sourceSets
.test
.runtimeClasspath
testClassesDirs = files(project(":sdks:java:extensions:sql").sourceSets.test.output.classesDirs)
useJUnit { }
}
task postCommit {
group = "Verification"
description = "Various integration tests"
dependsOn integrationTest
}
task emptyJar(type: Jar) {
archiveBaseName = "${project.archivesBaseName}-empty-jar"
from fileTree(dir: getTemporaryDir().createNewFile().toString())
}
task hadoopVersionsTest(group: "Verification") {
description = "Runs SQL tests with different Hadoop versions"
def taskNames = hadoopVersions.keySet().stream()
.map{num -> "hadoopVersion${num}Test"}
.collect(Collectors.toList())
dependsOn taskNames
}
hadoopVersions.each { kv ->
task "hadoopVersion${kv.key}Test"(type: Test, group: "Verification") {
description = "Runs SQL tests with Hadoop version $kv.value"
classpath = configurations."hadoopVersion$kv.key" + sourceSets.test.runtimeClasspath
include '**/*Test.class'
dependsOn emptyJar
// Pass jars used by Java UDF tests via system properties.
evaluationDependsOn(":sdks:java:extensions:sql:udf-test-provider") // Needed to resolve jarPath.
systemProperty "beam.sql.udf.test.jar_path", project(":sdks:java:extensions:sql:udf-test-provider").jarPath
systemProperty "beam.sql.udf.test.empty_jar_path", emptyJar.archivePath
}
}
test {
dependsOn emptyJar
// Pass jars used by Java UDF tests via system properties.
evaluationDependsOn(":sdks:java:extensions:sql:udf-test-provider") // Needed to resolve jarPath.
systemProperty "beam.sql.udf.test.jar_path", project(":sdks:java:extensions:sql:udf-test-provider").jarPath
systemProperty "beam.sql.udf.test.empty_jar_path", emptyJar.archivePath
}