import org.jsonschema2pojo.SourceType

plugins {
    id 'application'
    id 'airbyte-java-connector'
    id "io.airbyte.gradle.docker"
    id 'airbyte-connector-docker-convention'
    id 'com.github.eirnym.js2p'
}

tasks.named('sourcesJar').configure {
    dependsOn tasks.matching { it.name == 'generateJsonSchema2Pojo' }
}

airbyteJavaConnector {
    cdkVersionRequired = '0.37.0'
    features = ['db-sources']
    useLocalCdk = false
}

java {
    compileJava {
        options.compilerArgs += "-Xlint:-try,-rawtypes"
    }
}

airbyteJavaConnector.addCdkDependencies()

application {
    mainClass = 'io.airbyte.integrations.source.singlestore.SingleStoreSource'
}

dependencies {
    implementation 'com.singlestore:singlestore-jdbc-client:1.2.2'
    testImplementation 'org.apache.commons:commons-lang3:3.11'
    testFixturesImplementation 'org.testcontainers:jdbc:1.19.0'
    integrationTestJavaImplementation project(':airbyte-integrations:connectors:source-singlestore')
}

    jsonSchema2Pojo {
    sourceType = SourceType.YAMLSCHEMA
    source = files("${sourceSets.main.output.resourcesDir}/internal_models")
    targetDirectory = new File(project.buildDir, 'generated/src/gen/java/')
    removeOldOutput = true

    targetPackage = 'io.airbyte.integrations.source.singlestore.internal.models'

    useLongIntegers = true
    generateBuilders = true
    includeConstructors = false
    includeSetters = true
}

tasks.named('sourcesJar').configure {
    dependsOn tasks.named('generateJsonSchema2Pojo')
}
