/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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 {
    alias(libs.plugins.shadow)
}

apply from: "$rootDir/buildscripts/java-core.gradle"
apply from: "$rootDir/buildscripts/publishing.gradle"
apply from: "$rootDir/buildscripts/java-junit5.gradle"
apply from: "$rootDir/buildscripts/java-test-fixtures.gradle"
apply from: "$rootDir/buildscripts/java-integration-test.gradle"

dependencies {
    annotationProcessor libs.auto.service
    api project(':ignite-client-common')
    implementation project(':ignite-client')
    implementation project(':ignite-api')
    implementation project(':ignite-core')
    implementation project(':ignite-binary-tuple')
    implementation libs.jetbrains.annotations
    implementation libs.auto.service.annotations

    testImplementation testFixtures(project(":ignite-core"))

    integrationTestImplementation testFixtures(project(":ignite-api"))
    integrationTestImplementation testFixtures(project(":ignite-core"))
    integrationTestImplementation testFixtures(project(":ignite-sql-engine-api"))
    integrationTestImplementation testFixtures(project(":ignite-sql-engine"))
    integrationTestImplementation testFixtures(project(':ignite-jdbc'))
    integrationTestImplementation testFixtures(project(':ignite-runner'))
    integrationTestImplementation project(':ignite-transactions')
    integrationTestImplementation project(":ignite-runner")
    integrationTestImplementation project(":ignite-api")
    integrationTestImplementation project(":ignite-system-view-api")
    integrationTestImplementation libs.awaitility

    testFixturesImplementation testFixtures(project(":ignite-core"))
}

description = 'ignite-jdbc'

shadowJar {
    archiveClassifier.set('all')

    [
            'com.fasterxml',
            'com.google',
            'io.netty',
            'it.unimi',
            'org.jetbrains',
            'org.msgpack'
    ].forEach {
        relocate(it, "${project.group}.shaded.$it")
    }
    relocate('org.apache.ignite', "${project.group}.shaded.org.apache.ignite") {
        exclude('org.apache.ignite.jdbc.*')
        exclude('org.apache.ignite.internal.jdbc.*')
    }
}

configurations {
    jdbcRelease {
        canBeConsumed = true
        canBeResolved = false
    }
}

artifacts {
    jdbcRelease shadowJar
}

tasks.withType(Test).configureEach {
    jvmArgs += '-Dio.netty.leakDetectionLevel=paranoid'
}
