/*
 * This file is part of AndProx, an application for using Proxmark3 on Android.
 *
 * Copyright 2016-2018 Michael Farrell <micolous+git@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Under section 7 of the GNU General Public License v3, the following additional
 * terms apply to this program:
 *
 *  (b) You must preserve reasonable legal notices and author attributions in
 *      the program.
 *  (c) You must not misrepresent the origin of this program, and need to mark
 *      modified versions in reasonable ways as different from the original
 *      version (such as changing the name and logos).
 *  (d) You may not use the names of licensors or authors for publicity
 *      purposes, without explicit written permission.
 */

apply plugin: 'com.android.application'

task copyThirdPartyNotices(type: Copy) {
    from '../third_party/'
    into 'build/assets/third_party'
    eachFile { it.path = name }
    include 'NOTICE.GraphView.txt'
    include 'NOTICE.usb-serial-for-android.txt'
}

android {
    compileSdkVersion 28
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "au.id.micolous.andprox"
        // Must be at least the API version declared by all dependencies
        // Highest is natives @ API 21+
        minSdkVersion 21
        targetSdkVersion 28
        versionCode "git -C ${projectDir} rev-list --first-parent --count HEAD".execute().text.trim().toInteger()
        versionName "git -C ${projectDir} describe --always --tags --dirty".execute().text.trim().replaceAll("^v", "")
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        ndk.abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'

        // We only have English language support.
        resConfigs 'en'
    }
    dataBinding {
        enabled true
    }
    buildTypes {
        debug {
            minifyEnabled true
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        release {
            minifyEnabled true
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    preBuild.dependsOn copyThirdPartyNotices
    sourceSets {
        main.assets.srcDirs += ['build/assets']
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:support-v4:28.0.0'
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation project(':material-design-icons')
    implementation project(':usb-serial-for-android')

    // GPLv2 with linking exception
    implementation project(':GraphView')
    // implementation 'com.jjoe64:graphview:4.2.1'

    implementation "com.android.support:appcompat-v7:$support_version"
    implementation "com.android.support:design:$support_version"
    implementation "com.android.support:support-v4:$support_version"
    implementation "com.android.support:cardview-v7:$support_version"
    implementation "com.android.support:support-annotations:$support_version"

    testImplementation 'junit:junit:4.12'
    implementation project(':natives')
}

repositories {
    google()
}
