/*
 * Copyright 2024 Google LLC
 *
 * Licensed 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
 *
 *     https://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 'java'
    id 'application'
    id 'eclipse'
    id 'idea'
    id "com.diffplug.spotless" version "6.25.0"
}

repositories {
    mavenCentral()
    gradlePluginPortal()
}


def dataflowBeamVersion = '2.55.1'

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11

    toolchain {
        languageVersion = JavaLanguageVersion.of(11)
    }
}

group 'com.google.cloud.solution'
version '0.1.0'

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

dependencies {
    implementation platform('com.google.cloud:libraries-bom:26.29.0')

    implementation group: 'org.apache.beam', name: 'beam-sdks-java-core', version: dataflowBeamVersion
    implementation(group: 'org.apache.beam', name: 'beam-runners-google-cloud-dataflow-java', version: dataflowBeamVersion) {
        exclude group: 'io.confluent', module: 'kafka-schema-registry-client'
        exclude group: 'io.confluent', module: 'kafka-avro-serializer'
    }
    implementation group: 'com.google.cloud', name: 'google-cloud-bigquery'
    implementation group: 'org.apache.beam', name: 'beam-runners-direct-java', version: dataflowBeamVersion
    implementation group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.5'
    implementation group: 'com.google.auto.value', name: 'auto-value-annotations', version: '1.7.4'
    annotationProcessor group: 'com.google.auto.value', name: 'auto-value', version: '1.7.4'
    testImplementation group: 'org.apache.beam', name: 'beam-runners-direct-java', version: dataflowBeamVersion
    testImplementation group: 'org.hamcrest', name: 'hamcrest-core', version: '1.3'
    testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
    testImplementation group: 'junit', name: 'junit', version: '4.13.2'
}

compileJava {
    // Add additional jvm argument
    options.compilerArgs.addAll(['-Xlint:all', '-Xlint:-processing'])
}

defaultTasks 'clean', 'assemble'


application {
    mainClass.set("com.google.cloud.dataflow.SpannerToBigQueryUsingCdc")
}

spotless {
    java {
        target "**/*.java"
        removeUnusedImports()
        importOrder()
        googleJavaFormat()
    }
}
