/*
 * Copyright 2018 Alibaba Group.
 *
 * Licensed 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.
 */

version 'unspecified'
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8


repositories {
    mavenCentral()
    jcenter()
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def bintray_user = properties.getProperty('BINTRAY_USER')
def bintray_key = properties.getProperty('BINTRAY_KEY')


bintray {
    user = bintray_user
    key = bintray_key
    publish = true
    override = true
    publications = ['maven_android']
    pkg {
        repo = 'maven'
        name = 'jsonlube'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://github.com/alibaba/jsonlube'

        version {
            name = '1.0.0.3'
            desc = 'A json parser generator in compile time.'
            released  = new Date()
            vcsTag = '1.0.0.3'
        }
    }
}

task sourceJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

publishing {
    publications {
        maven_android(MavenPublication) {
            groupId "com.alibaba.android"
            version "1.0.0.3"
            artifactId "jsonlube"
            artifact("$buildDir/outputs/aar/jsonlube-release.aar")
            artifact(sourceJar)

            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')

                //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
                configurations.compile.allDependencies.each {
                    if (it.group != null && it.group != 'unspecified' && it.name != null && it.name != 'unspecified') {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
            }
        }
    }
}


android {
    compileSdkVersion 25

    buildToolsVersion "25.0.3"
    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 26
//        multiDexEnabled true
        ndk {
            abiFilters "armeabi", /*"armeabi-v7a",*/ "x86"
        }

        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath = true
            }
        }
    }

    lintOptions {
        textReport true
        textOutput 'stdout'
        // We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
        checkReleaseBuilds false
    }
}

dependencies {
    compile files(fileTree(dir: 'lib', includes: ['*.jar']))
    compile group:'com.alibaba.android', name :'jsonlube-annotations', version :'1.0.0.3'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}
