/*
 * Copyright (c) 2022, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * 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 "com.github.johnrengelman.shadow"
}

apply from: "$rootDir/gradle/javaProject.gradle"

description = 'Ballerina - C2C Extension'

configurations {
    fatJar {
        extendsFrom implementation
        exclude group: "io.netty"
        exclude group: "org.javassist"
        exclude group: "com.google.guava"
        exclude group: "com.fasterxml.jackson.core"
        exclude group: "com.fasterxml.jackson.dataformat"
        exclude group: "com.fasterxml.jackson.module"
        exclude group: "org.glassfish.hk2.external"
        exclude group: "org.slf4j"
        exclude group: "org.apache.commons"
        exclude group: "commons-io"
        exclude group: "commons-logging"
        exclude group: "com.github.mifmif"
        exclude group: "dk.brics.automaton"
        exclude group: "io.fabric8", module: "zjsonpatch"
        exclude group: "com.squareup.okhttp3"
        exclude group: "com.squareup.okio"
        exclude group: "org.antlr"
        exclude group: "org.joda", module: "joda-convert"
        exclude group: "org.ballerinalang"
    }
}

dependencies {
    implementation project(":cloud-util")

    implementation group: 'com.google.code.gson', name: 'gson', version: "${googleGsonVersion}"
    
    implementation group: 'io.fabric8', name: 'kubernetes-model-core', version: "${fabric8KubernetesClientVersion}"
    implementation group: 'io.fabric8', name: 'kubernetes-model-apps', version: "${fabric8KubernetesClientVersion}"
    implementation group: 'io.fabric8', name: 'kubernetes-model-autoscaling', version: "${fabric8KubernetesClientVersion}"
    implementation group: 'io.fabric8', name: 'kubernetes-model-batch', version: "${fabric8KubernetesClientVersion}"
    implementation group: 'io.fabric8', name: 'openshift-client', version: "${fabric8KubernetesClientVersion}"

    implementation group: 'org.ballerinalang', name: 'ballerina-cli', version: "${ballerinaLangVersion}"
    implementation group: 'org.ballerinalang', name: 'ballerina-lang', version: "${ballerinaLangVersion}"
    implementation group: 'org.ballerinalang', name: 'ballerina-tools-api', version: "${ballerinaLangVersion}"
    implementation group: 'org.ballerinalang', name: 'ballerina-parser', version: "${ballerinaLangVersion}"
    implementation group: 'org.ballerinalang', name: 'toml-parser', version: "${ballerinaLangVersion}"
    implementation group: 'org.ballerinalang', name: 'testerina-runtime', version: "${ballerinaLangVersion}"

    implementation group: 'org.slf4j', name: 'slf4j-log4j12', version: "${slf4jVersion}"
    implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: "${jacksonYamlVersion}"
    implementation group: 'commons-io', name: 'commons-io', version: "${commonIoVersion}"
    implementation group: 'commons-codec', name: 'commons-codec', version: "${commonsCodecVersion}"

    compileOnly group: 'org.projectlombok', name: 'lombok', version: "${lombokVersion}"

    annotationProcessor group: 'org.projectlombok', name: 'lombok', version: "${lombokVersion}"

    testImplementation group: 'org.ballerinalang', name: 'ballerina-lang', version: "${ballerinaLangVersion}"
    testImplementation group: 'org.slf4j', name: 'slf4j-api', version: "${slf4jVersion}"
    testImplementation group: 'org.slf4j', name: 'slf4j-log4j12', version: "${slf4jVersion}"
    testImplementation group: 'org.testng', name: 'testng', version: "${testngVersion}"

    checkstyle project(":checkstyle")
    checkstyle "com.puppycrawl.tools:checkstyle:${puppycrawlCheckstyleVersion}"
}

jar {
    enabled = false
    dependsOn(shadowJar {
        project.configurations.implementation.canBeResolved = true
        configurations = [project.configurations.fatJar]
        exclude 'cloud-compiler-plugin'
        archiveClassifier = null
    })
}

test {
    useTestNG() {
        suites 'src/test/resources/testng.xml'
    }
    systemProperties = [
            buildDir: System.getProperty('buildDir', "$project.buildDir")
    ]
}
