apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.protobuf'

apply from: project(':common').projectDir.absolutePath + '/variables.gradle'


buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.6'
    }
}

repositories {
    jcenter()
    maven {
        url 'https://maven.google.com'
    }
}

sourceSets {
    main.java.srcDirs += "${protobuf.generatedFilesBaseDir}/main/java"
}

android {
    compileSdkVersion 26
    defaultConfig {
        minSdkVersion 19
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:support-v4:$android_support_version"
    implementation "com.android.support:support-vector-drawable:$android_support_version"
    implementation "com.android.support:appcompat-v7:$android_support_version"
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.protobuf:protobuf-lite:3.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

protobuf {
    protoc {
        // You still need protoc like in the non-Android case
        artifact = 'com.google.protobuf:protoc:3.0.0'
    }
    plugins {
        javalite {
            // The codegen for lite comes as a separate artifact
            artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0'
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                // In most cases you don't need the full Java output
                // if you use the lite output.
                remove java
            }
            task.plugins {
                javalite {}
            }
        }
    }
}
