
/*
 * 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 'org.javacc.javacc'
}
applyJavaNature(
  automaticModuleName: 'org.apache.beam.sdk.io.clickhouse',
  generatedClassPatterns: [
    /^org\.apache\.beam\.sdk\.io\.clickhouse\.impl\.parser\..*/,
  ],
  // javacc generated code produces lint warnings
  disableLintWarnings: ['dep-ann'],
)

description = "Apache Beam :: SDKs :: Java :: IO :: ClickHouse"
ext.summary = "IO to write to ClickHouse (https://clickhouse.yandex)."

// Match the output directory for generated code with the package, to be more tool-friendly
def generatedJavaccSourceDir = "${project.buildDir}/generated/javacc"
def generatedJavaccPackageDir =
        "${generatedJavaccSourceDir}/org/apache/beam/sdk/io/clickhouse/impl/parser"
compileJavacc {
  outputDirectory = file(generatedJavaccPackageDir)
  arguments = [static: "false"]
}

// Help IntelliJ finding generated code
idea {
  module {
    sourceDirs += file(generatedJavaccSourceDir)
    generatedSourceDirs += file(generatedJavaccSourceDir)
  }
}

def clickhouse_jdbc_version = "0.6.4"

dependencies {
  javacc "net.java.dev.javacc:javacc:7.0.9"
  implementation project(path: ":sdks:java:core", configuration: "shadow")
  implementation library.java.guava
  implementation library.java.joda_time
  implementation library.java.slf4j_api
  implementation library.java.vendored_guava_32_1_2_jre
  implementation "com.clickhouse:clickhouse-jdbc:$clickhouse_jdbc_version:all"
  testImplementation library.java.slf4j_api
  testImplementation library.java.junit
  testImplementation library.java.hamcrest
  testImplementation library.java.testcontainers_clickhouse
  testRuntimeOnly library.java.slf4j_jdk14
  testRuntimeOnly project(path: ":runners:direct-java", configuration: "shadow")
}

processTestResources {
  // BEAM-12390: config.d/zookeeper_default.xml should have xx4 permission.
  fileMode 0644
}
