/*
 * 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.slf4jVersion = property('slf4j.version')
ext.junitVersion = property('junit.version')
ext.mockitoVersion = property('mockito.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:servlet-api:${servletVersion}"

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