/*
 * 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.
 */

// Using the legacy plugin classpath for Clover so it can be loaded optionally
buildscript {
    // strictly enforce the minimum version of Java required to build and fail fast
    if (JavaVersion.current() < JavaVersion.VERSION_1_8) {
        throw new GradleException("The java version used is ${JavaVersion.current()}, but must be at least ${JavaVersion.VERSION_1_8}")
    }

    repositories {
        mavenCentral()
        google()
        gradlePluginPortal()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-clover-plugin:2.2.1'
    }
}

plugins {
    id 'java-library'
    id 'maven-publish'
    id 'signing'
    id 'pmd'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
    id "com.github.spotbugs" version "5.0.14"
    id "com.diffplug.spotless" version "6.19.0"
}

description = 'Apache Thrift Java Library'

defaultTasks 'build'

// Version components for this project
group = property('thrift.groupid')

if (Boolean.parseBoolean(project.release)) {
    version = property('thrift.version')
} else {
    version = property('thrift.version') + '-SNAPSHOT'
}

// Keeping the rest of the build logic in functional named scripts for clarity
apply from: 'gradle/environment.gradle'
apply from: 'gradle/sourceConfiguration.gradle'
apply from: 'gradle/generateTestThrift.gradle'
apply from: 'gradle/unitTests.gradle'
apply from: 'gradle/cloverCoverage.gradle'
apply from: 'gradle/functionalTests.gradle'
apply from: 'gradle/publishing.gradle'
apply from: 'gradle/codeQualityChecks.gradle'
