/*
 * Copyright 2021 DataCanvas
 *
 * 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
 *
 *     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 'application'
    id 'java-conventions'
    id "com.gorylenko.gradle-git-properties" version "${gradleGitCommitVersion}"
}

application {
    mainClassName = 'io.dingodb.server.executor.Starter'
}

dependencies {
    annotationProcessor group: 'com.google.auto.service', name: 'auto-service', version: 'auto-service'.v()
    compileOnly group: 'com.google.auto.service', name: 'auto-service', version: 'auto-service'.v()

    implementation group: 'ch.qos.logback', name: 'logback-core', version: 'logback'.v()
    implementation group: 'ch.qos.logback', name: 'logback-classic', version: 'logback'.v()
    implementation group: 'com.beust', name: 'jcommander', version: 'jcommander'.v()
    implementation group: 'org.apache.calcite.avatica', name: 'avatica-server', version: 'avatica'.v()
    implementation group: 'org.quartz-scheduler', name: 'quartz', version: 'quartz'.v()

    implementation group: 'io.dingodb', name: 'dingo-sdk', version: project.version

    implementation project(":dingo-common")
    implementation project(":dingo-calcite")
    implementation project(":dingo-verify")

    implementation project(":dingo-codec-api")
    implementation project(':dingo-net-api')
    implementation project(":dingo-store-api")
    implementation project(":dingo-scheduler-api")
    implementation project(":dingo-tool-api")
    implementation project(':dingo-store-proxy')
    implementation project(":dingo-partition-base")
    implementation project(":dingo-tool-service")
    implementation project(":dingo-transaction-api")
    implementation project(":dingo-license-api")

    implementation project(":dingo-driver:dingo-mysql-service")

    implementation project(':dingo-driver:dingo-driver-host')
    implementation project(':dingo-driver:dingo-driver-client')
    implementation group: 'com.alibaba', name: 'fastjson', version: 'fastjson'.v()
    implementation group: 'org.apache.commons', name: 'commons-pool2', version: 'commons-pool2'.v()
    testImplementation project(":dingo-store-local")
}

task fatJar(type: Jar) {
    manifest {
        attributes 'Main-Class': 'io.dingodb.server.executor.Starter'
    }
    classifier 'all'
    zip64=true
    from(
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) },
    )
    with jar

    exclude "META-INF/*.SF"
    exclude "META-INF/*.DSA"
    exclude "META-INF/*.RSA"
}

tasks.named("build") { x ->
    x.finalizedBy("fatJar")
}
