| /* |
| * 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 java.util.stream.Collectors |
| |
| plugins { id 'org.apache.beam.module' } |
| applyJavaNature(automaticModuleName: 'org.apache.beam.sdk.io.hcatalog') |
| |
| description = "Apache Beam :: SDKs :: Java :: IO :: HCatalog" |
| ext.summary = "IO to read and write for HCatalog source." |
| |
| def hadoopVersions = [ |
| "285": "2.8.5", |
| "292": "2.9.2", |
| "2101": "2.10.1", |
| ] |
| |
| hadoopVersions.each {kv -> configurations.create("hadoopVersion$kv.key")} |
| |
| def hive_version = "2.1.0" |
| |
| test { |
| // TODO: Get tests to run. Known issues: |
| // * calcite-avatica bundles w/o repackaging Jackson (CALCITE-1110) |
| // * hive-exec bundles w/o repackaging Guava (HIVE-13690) |
| ignoreFailures true |
| } |
| |
| configurations.testRuntimeClasspath { |
| resolutionStrategy { |
| def log4j_version = "2.4.1" |
| // Beam's build system forces a uniform log4j version resolution for all modules, however for |
| // the HCatalog case the current version of log4j produces NoClassDefFoundError so we need to |
| // force an old version on the tests runtime classpath |
| force "org.apache.logging.log4j:log4j-api:${log4j_version}" |
| force "org.apache.logging.log4j:log4j-core:${log4j_version}" |
| } |
| } |
| |
| /* |
| * We need to rely on manually specifying these evaluationDependsOn to ensure that |
| * the following projects are evaluated before we evaluate this project. This is because |
| * we are attempting to reference the "sourceSets.test.output" directly. |
| * TODO: Swap to generating test artifacts which we can then rely on instead of |
| * the test outputs directly. |
| */ |
| evaluationDependsOn(":sdks:java:io:common") |
| |
| dependencies { |
| compile library.java.vendored_guava_26_0_jre |
| compile project(path: ":sdks:java:core", configuration: "shadow") |
| compile project(":sdks:java:io:hadoop-common") |
| compile library.java.slf4j_api |
| compile library.java.joda_time |
| // Hive bundles without repackaging Jackson which is why we redeclare it here so that it appears |
| // on the compile/test/runtime classpath before Hive. |
| provided library.java.jackson_annotations |
| provided library.java.jackson_core |
| provided library.java.jackson_databind |
| // Calcite (a dependency of Hive) bundles without repackaging Guava which is why we redeclare it |
| // here so that it appears on the compile/test/runtime classpath before Calcite. |
| provided library.java.hadoop_common |
| provided "org.apache.hive:hive-exec:$hive_version" |
| provided(group: "org.apache.hive.hcatalog", name: "hive-hcatalog-core", version: hive_version) { |
| exclude group: "org.apache.hive", module: "hive-exec" |
| exclude group: "com.google.protobuf", module: "protobuf-java" |
| } |
| testCompile project(":sdks:java:io:common").sourceSets.test.output |
| testCompile library.java.commons_io |
| testCompile library.java.junit |
| testCompile library.java.hamcrest_core |
| testCompile library.java.hamcrest_library |
| testCompile "org.apache.hive.hcatalog:hive-hcatalog-core:$hive_version:tests" |
| testCompile "org.apache.hive:hive-exec:$hive_version" |
| testCompile "org.apache.hive:hive-common:$hive_version" |
| testCompile "org.apache.hive:hive-cli:$hive_version" |
| testRuntimeOnly project(path: ":runners:direct-java", configuration: "shadow") |
| hadoopVersions.each {kv -> |
| "hadoopVersion$kv.key" "org.apache.hadoop:hadoop-common:$kv.value" |
| } |
| } |
| |
| hadoopVersions.each {kv -> |
| configurations."hadoopVersion$kv.key" { |
| resolutionStrategy { |
| force "org.apache.hadoop:hadoop-common:$kv.value" |
| } |
| } |
| } |
| |
| task hadoopVersionsTest(group: "Verification") { |
| description = "Runs HCatalog 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 HCatalog tests with Hadoop version $kv.value" |
| classpath = configurations."hadoopVersion$kv.key" + sourceSets.test.runtimeClasspath |
| include '**/*Test.class' |
| } |
| } |