/*
 * 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 {
    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'
