/*
 * fdb-record-layer-core.gradle
 *
 * This source file is part of the FoundationDB open source project
 *
 * Copyright 2015-2018 Apple Inc. and the FoundationDB project authors
 *
 * 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 {
    alias(libs.plugins.shadow)
}
apply from: rootProject.file('gradle/proto.gradle')
apply from: rootProject.file('gradle/publishing.gradle')

dependencies {
    annotationProcessor project(':fdb-java-annotations')
    api project(':fdb-extensions')

    api(libs.protobuf)
    implementation(libs.slf4j.api)
    implementation(libs.guava)
    compileOnly(libs.jsr305)
    compileOnly(libs.autoService)
    annotationProcessor(libs.autoService)

    testImplementation testFixtures(project(':fdb-extensions'))
    testImplementation(libs.bundles.test.impl)
    testRuntimeOnly(libs.bundles.test.runtime)
    testCompileOnly(libs.bundles.test.compileOnly)
    testImplementation(libs.jcommander)
    testImplementation(libs.apache.commonsMath3)
    testImplementation(libs.junit.platform)
    testImplementation(libs.protobuf.util)
    testCompileOnly(libs.spotbugs.annotations)

    testAnnotationProcessor(libs.autoService)
}

sourceSets {
    main {
        java.srcDir ".out/generated/sources/annotationProcessor/java/main/"
    }
}

task testShadowJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
    archiveClassifier = 'standalone-tests'
    from sourceSets.main.output
    from sourceSets.test.output
    configurations = [ project.configurations.testRuntimeClasspath ]
    manifest {
        inheritFrom project.tasks.jar.manifest
        attributes 'Main-Class': 'com.apple.foundationdb.record.provider.foundationdb.FDBRecordStorePerformanceTest',
                   'Multi-Release': 'true' // https://github.com/johnrengelman/shadow/issues/449
    }
    mergeServiceFiles()
    exclude 'log4j.properties'
}

publishing {
    publications {
        library(MavenPublication) {
            pom {
                // Normally, the variable would be included within the string using variable expansion in a Groovy
                // string. However, the "description" field must be a java.lang.String, hence the use of string
                // concatenation here.
                description = 'A record-oriented layer built for FoundationDB.'
            }
        }
    }
}
