apply plugin: 'com.android.application'
apply from: new File(rootProject.projectDir, 'gradle/previewBuild.gradle')

android {
    compileSdkVersion 32

    defaultConfig {
        applicationId "com.calsignlabs.apde"
        minSdkVersion 19
        targetSdkVersion 32
        versionCode 33
        versionName "0.5.2-pre2"
        multiDexEnabled true

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments clearPackageData: 'true'

        buildConfigField 'String', 'COMMON_R_JAVA_PACKAGE', '"' + rootProject.commonRJavaPackage + '"'
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
            multiDexKeepProguard file('multidex-config.pro')

            lintOptions {
                disable 'MissingTranslation'
            }
        }

        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
            multiDexKeepProguard file('multidex-config.pro')
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "2048M"
    }

    sourceSets {
        main {
            res.srcDirs = ['src/main/res']
            java.srcDirs = ['src/main/java']
            // assets we extract from downloaded files (Processing and Android mode)
            assets.srcDirs += [project.additionalAssets]
        }
        test {
            java.srcDirs = ['src/test/java']
        }
        androidTest {
            java.srcDirs = ['src/androidTest/java']
        }
    }
    packagingOptions {
        jniLibs {
            excludes += ['META-INF/*', 'about_files/*']
        }
        resources {
            excludes += ['plugin.xml', 'plugin.properties', 'META-INF/*', 'about_files/*', '*.html']
        }
    }


    useLibrary 'android.test.runner'
    useLibrary 'android.test.base'
    useLibrary 'android.test.mock'

    testOptions {
        animationsDisabled true
    }
    lint {
        abortOnError false
    }
    namespace 'com.calsignlabs.apde'
}

preBuild.dependsOn project.createAdditionalAssets
preBuild.dependsOn project.assetPreviewBuildZip

dependencies {
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation files(project.androidCore)
    implementation project.javaMode
    implementation project.pde
    implementation files('libs/antlr.jar')
    implementation files('libs/core-1.51.0.0.jar')
    implementation files('libs/dx.jar')
    implementation files('libs/jsch-0.1.51.jar')
    implementation files('libs/kellinwood-logging-android-1.4.jar')
    implementation files('libs/kellinwood-logging-lib-1.1.jar')
    implementation files('libs/org.eclipse.jgit-3.5.2.201411120430-r.jar')
    implementation files('libs/pkix-1.51.0.0.jar')
    implementation files('libs/prov-1.51.0.0.jar')
    implementation files('libs/sdklib.jar')
    implementation files('libs/zipio-lib-1.8.jar')
    implementation files('libs/zipsigner-lib-1.17.jar')
    implementation files('libs/zipsigner-lib-optional-1.17.jar')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.5.1'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'com.takisoft.preferencex:preferencex:1.1.0'
    implementation 'com.google.android.gms:play-services-auth:20.3.0'
    implementation 'com.google.android.gms:play-services-wearable:17.1.0'
    implementation 'androidx.test.espresso.idling:idling-concurrent:3.4.0'

    // unit testing
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'androidx.test.ext:junit:1.1.3'
    testImplementation 'androidx.test.ext:truth:1.4.0'
    testImplementation 'com.google.truth:truth:1.0.1'

    // integration testing
    androidTestImplementation 'androidx.test:core:1.4.0'
    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:rules:1.4.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.ext:truth:1.4.0'
    androidTestImplementation 'com.google.truth:truth:1.0.1'

    // espresso
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-idling-resource:3.4.0'

    // ui automator
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
}
