/*
 * 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: 'maven-publish'
apply plugin: 'java-library'
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'com.jfrog.bintray'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

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')

repositories {
    mavenCentral()
    jcenter()
}

shadowJar {
    baseName = 'jsonlube-compiler'
    classifier = null
    version = null
}

test {
    testLogging.showStandardStreams = true
}

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.10'
            desc = 'A json parser generator in compile time.'
            released  = new Date()
            vcsTag = '1.0.0.10'
        }
    }
}

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

publishing {
    publications {
        maven_android(MavenPublication) {
            groupId "com.alibaba.android"
            version "1.0.0.10"
            artifactId "jsonlube-compiler"
            artifact("$buildDir/libs/jsonlube-compiler.jar")
            artifact(sourceJar)
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':jsonlube-annotations')
    implementation 'com.squareup:javapoet:1.10.0'
    implementation 'com.alibaba:fastjson:1.1.67.android'
    implementation 'com.google.auto:auto-common:0.9'
    implementation 'com.google.auto.service:auto-service:1.0-rc4'
    testImplementation 'junit:junit:4.12'
    testImplementation 'com.google.testing.compile:compile-testing:0.13'
    testImplementation group: 'com.vaadin.external.google', name: 'android-json', version: '0.0.20131108.vaadin1'
    implementation files(org.gradle.internal.jvm.Jvm.current().toolsJar)
}