/*
 * 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()
        jcenter()
        gradlePluginPortal()
    }

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

plugins {
    id 'java'
    id 'maven'
    id 'signing'
    id 'com.github.johnrengelman.shadow' version '4.0.4'
    id "com.github.spotbugs" version "2.0.0"
}

ext {
    // https://github.com/spotbugs/spotbugs-gradle-plugin/issues/32#issuecomment-409951172
    SpotBugsTask = com.github.spotbugs.SpotBugsTask
}

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/additionalArtifacts.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'
