| import groovy.json.JsonOutput |
| |
| /* |
| * 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 'org.apache.beam.module' |
| id 'ca.coglinc.javacc' |
| } |
| applyJavaNature( |
| // javacc generated code produces lint warnings |
| disableLintWarnings: ['dep-ann'], |
| testShadowJar: true, |
| enableStrictDependencies: true, |
| shadowClosure: DEFAULT_SHADOW_CLOSURE << { |
| dependencies { |
| include(dependency(library.java.protobuf_java)) |
| include(dependency(library.java.protobuf_java_util)) |
| include(dependency("org.apache.calcite:.*")) |
| include(dependency("org.apache.calcite.avatica:.*")) |
| include(dependency("org.codehaus.janino:.*")) |
| } |
| relocate "com.google.protobuf", getJavaRelocatedPath("com.google.protobuf") |
| relocate "org.apache.calcite", getJavaRelocatedPath("org.apache.calcite") |
| |
| // Looking up the compiler factory in Calcite depends on having a properties |
| // file in the right location. We package one that is shading compatible |
| // in src/main/resources. Note that if this shaded path changes, that |
| // files name and contents need to be updated as well. TODO, swap to use |
| // getJavaRelocatedPath once the Maven build is no longer also shading this |
| // module. |
| relocate "org.codehaus", "org.apache.beam.sdks.java.extensions.sql.repackaged.org.codehaus" |
| }) |
| |
| 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 calcite_version = "1.19.0" |
| def avatica_version = "1.15.0" |
| |
| dependencies { |
| 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.28" |
| fmppTemplates "org.apache.calcite:calcite-core:$calcite_version" |
| shadow library.java.vendored_guava_20_0 // Internal use |
| compile library.java.guava // Interfaces with Calcite use this |
| compile "org.apache.calcite:calcite-core:$calcite_version" |
| compile "org.apache.calcite:calcite-linq4j:$calcite_version" |
| compile "org.apache.calcite.avatica:avatica-core:$avatica_version" |
| shadow project(path: ":sdks:java:core", configuration: "shadow") |
| shadow project(path: ":sdks:java:extensions:join-library", configuration: "shadow") |
| shadow library.java.slf4j_api |
| shadow library.java.commons_codec |
| shadow library.java.commons_csv |
| shadow library.java.commons_lang3 |
| shadow library.java.jackson_databind |
| shadow library.java.jackson_dataformat_yaml |
| shadow library.java.joda_time |
| shadow "com.alibaba:fastjson:1.2.49" |
| shadow "com.jayway.jsonpath:json-path:2.4.0" |
| shadow project(path: ":runners:direct-java", configuration: "shadow") |
| provided project(path: ":sdks:java:io:kafka", configuration: "shadow") |
| provided project(path: ":sdks:java:io:google-cloud-platform", configuration: "shadow") |
| provided library.java.kafka_clients |
| shadowTest library.java.junit |
| shadowTest library.java.hamcrest_core |
| shadowTest library.java.hamcrest_library |
| shadowTest library.java.mockito_core |
| shadowTest library.java.quickcheck_core |
| shadowTestRuntimeClasspath library.java.slf4j_jdk14 |
| |
| // Dependencies that we don't directly reference |
| permitUnusedDeclared "com.jayway.jsonpath:json-path:2.4.0" |
| permitUnusedDeclared library.java.jackson_dataformat_yaml |
| |
| // Dependencies that are bundled in when we bundle Calcite |
| permitUsedUndeclared "org.codehaus.janino:janino:3.0.11" |
| permitUsedUndeclared "org.codehaus.janino:commons-compiler:3.0.11" |
| |
| // Dependencies where one or the other appears "used" depending on classpath, |
| // but it doesn't matter which is used |
| permitUsedUndeclared "com.google.code.findbugs:jsr305:3.0.2" |
| permitUnusedDeclared "net.jcip:jcip-annotations:1.0" |
| } |
| |
| // Copy Caclcite 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("calcite-core") |
| }.singleFile |
| from zipTree(calciteCoreJar) |
| include "**/Parser.jj" |
| into "${project.buildDir}/templates-fmpp" |
| } |
| |
| // 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" |
| main = "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" |
| main = "org.apache.beam.sdk.extensions.sql.example.BeamSqlPojoExample" |
| classpath = sourceSets.main.runtimeClasspath |
| args = ["--runner=DirectRunner"] |
| } |
| |
| task integrationTest(type: Test) { |
| group = "Verification" |
| 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 |
| } |