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

// Following Gradle best practices to keep build logic organized

// Override the build directory if CMake is used (allows for out-of-tree-builds)
if (hasProperty('build.dir')) {
    buildDir = file(property('build.dir'))
}

// In order to remain compatible with other Ant based builds in the system
// we convert the gradle.properties into DSL friendly camelCased properties
ext.installPath = property('install.path')
ext.installJavadocPath = property('install.javadoc.path')

ext.thriftRoot = file('../..')

if (hasProperty('thrift.compiler')) {
    ext.thriftCompiler = property('thrift.compiler')
} else {
    ext.thriftCompiler = "$thriftRoot/compiler/cpp/thrift"
}

ext.mvnRepo = property('mvn.repo')
ext.apacheRepo = property('apache.repo')
ext.mavenRepositoryUrl = property('maven-repository-url')

// Versions used in this project
ext.httpclientVersion = property('httpclient.version')
ext.httpcoreVersion = property('httpcore.version')
ext.servletVersion = property('servlet.version')
ext.tomcatEmbedVersion = property('tomcat.embed.version')
ext.slf4jVersion = property('slf4j.version')
ext.junitVersion = property('junit.version')
ext.mockitoVersion = property('mockito.version')
ext.javaxAnnotationVersion = property('javax.annotation.version')

// In this section you declare where to find the dependencies of your project
repositories {
    maven {
        name 'Maven Central Repository'
        url mvnRepo
    }
    maven {
        name 'Apache Maven Repository'
        url apacheRepo
    }
}

dependencies {
    compile "org.slf4j:slf4j-api:${slf4jVersion}"
    compile "org.apache.httpcomponents:httpclient:${httpclientVersion}"
    compile "org.apache.httpcomponents:httpcore:${httpcoreVersion}"
    compile "javax.servlet:javax.servlet-api:${servletVersion}"
    compile "javax.annotation:javax.annotation-api:${javaxAnnotationVersion}"
    compile "org.apache.commons:commons-lang3:3.12.0"

    testCompile "junit:junit:${junitVersion}"
    testCompile "org.mockito:mockito-all:${mockitoVersion}"
    testRuntime "org.slf4j:slf4j-log4j12:${slf4jVersion}"
}
