plugins {
  id 'antlr'
  id "com.github.davidmc24.gradle.plugin.avro" version "1.3.0"
}

dependencies {
  api project(":api")

  implementation group: 'commons-io', name: 'commons-io', version: commonsIoVersion
  implementation group: 'commons-cli', name: 'commons-cli', version: commonsCliVersion
  implementation group: 'org.apache.commons', name: 'commons-csv', version: commonsCsvVersion
  implementation group: 'software.amazon.awssdk', name: 's3', version: awsVersion
  implementation group: 'software.amazon.awssdk', name: 'kinesis', version: awsVersion
  implementation group: 'software.amazon.awssdk', name: 's3-transfer-manager', version: awsVersion

  implementation group: 'software.amazon.kinesis', name: 'amazon-kinesis-client', version: awsKensisClientVersion
  implementation group: 'software.amazon.awssdk', name: 'dynamodb', version: awsVersion
  implementation group: 'software.amazon.awssdk', name: 'cloudwatch', version: awsVersion

  implementation group: 'org.apache.kafka', name: 'kafka-clients', version: kafkaVersion
  implementation group: 'com.clickhouse', name: 'client-v2', version: clickHouseVersion

  implementation group: 'org.graalvm.sdk', name: 'graal-sdk', version: graalvmVersion
  runtimeOnly group: 'org.graalvm.polyglot', name: 'python', version: graalvmVersion

  implementation group: 'com.clickhouse', name: 'clickhouse-jdbc', version: clickHouseVersion

  implementation group: 'org.apache.hadoop', name: 'hadoop-common', version: hadoopVersion
  implementation group: 'org.apache.hadoop', name: 'hadoop-client', version: hadoopVersion
  implementation('org.apache.hadoop:hadoop-aws:' + hadoopVersion) {
    exclude group: 'software.amazon.awssdk', module: 'bundle'
  }

  implementation group: 'io.delta', name: 'delta-kernel-api', version: deltaKernelVersion
  implementation group: 'io.delta', name: 'delta-kernel-defaults', version: deltaKernelVersion

  testImplementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: jacksonVersion
  testImplementation group: 'org.testcontainers', name: 'clickhouse', version: testContainersVersion

  antlr "org.antlr:antlr4:${antlrVersion}"
}

configurations.all {
  exclude group: 'log4j', module: 'log4j'
  exclude group: 'dnsjava', module: 'dnsjava'
}


generateGrammarSource {
  arguments << "-lib" << "src/main/antlr/io/fleak/zephflow/lib/antlr"
  arguments += ['-visitor', '-package', 'io.fleak.zephflow.lib.antlr']
  maxHeapSize = '64m'
  outputDirectory = file("${project.buildDir}/generated/sources/main/java")
  mustRunAfter tasks.named('licenseMain')
}

generateAvroJava {
  source('src/main/avro')
  outputDir = file("${buildDir}/generated/sources/main/java")
  mustRunAfter tasks.named('licenseMain')
}

sourceSets {
  main {
    java {
      srcDirs += "${project.buildDir}/generated/sources/main/java"
    }
  }
}

tasks.named('test') {
  useJUnitPlatform()
  testLogging.showStandardStreams = true
}

tasks.named('sourcesJar') {
  dependsOn 'generateGrammarSource'
  duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}