mobile/android/geckoview_example/build.gradle
author Nick Alexander <nalexander@mozilla.com>
Wed, 21 Jun 2017 10:52:30 -0700
changeset 368830 a419686f707e7a248a3b477556fef8b8ae7d6bae
parent 317079 5f36cae0e01f2e9c447ae0481a97affb8ee52097
child 377612 2f4ec6a1b39e1ce97cd238a015b1a336bded7f2a
permissions -rw-r--r--
Bug 1352602 - Part 2: Use build system SDK versions in Gradle configurations. r=maliu This patch does two things: - add a Gradle-only ANDROID_COMPILE_SDK_VERSION substitution; - uses it while uniformizing all of the Gradle Android SDK version configurations. The approach is fairly standard (and we were using it already); see, for example https://medium.com/@ali.muzaffar/gradle-configure-variables-for-all-android-project-modules-in-one-place-5a6e56cd384e This will make bumping the Gradle configuration versions forward easier. MozReview-Commit-ID: 1j5siCvR5qt

buildDir "${topobjdir}/gradle/build/mobile/android/geckoview_example"

apply plugin: 'com.android.application'

android {
    compileSdkVersion project.ext.compileSdkVersion
    buildToolsVersion project.ext.buildToolsVersion

    defaultConfig {
        targetSdkVersion project.ext.targetSdkVersion
        minSdkVersion project.ext.minSdkVersion
        manifestPlaceholders = project.ext.manifestPlaceholders

        applicationId "org.mozilla.geckoview_example"
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    // This is extremely frustrating, but the only way to do it automation for
    // now.  Without this, we only get a "debugAndroidTest" configuration; we
    // have no "withoutGeckoBinariesAndroidTest" configuration.
    testBuildType "withoutGeckoBinaries"
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        withGeckoBinaries { // For consistency with :geckoview project in Task Cluster invocations.
            initWith debug
        }
        withoutGeckoBinaries { // Logical negation of withGeckoBinaries.
            initWith debug
        }
    }
}

dependencies {
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:support-annotations:23.4.0'

    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    androidTestCompile 'com.android.support.test:runner:0.5'
    // Not defining this library again results in test-app assuming 23.1.1, and the following errors:
    // "Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.4.0) and test app (23.1.1) differ."
    androidTestCompile 'com.android.support:support-annotations:23.4.0'

    compile project(':geckoview')
}

apply from: "${topsrcdir}/mobile/android/gradle/with_gecko_binaries.gradle"

android.applicationVariants.all { variant ->
    // Like 'debug', 'release', or 'withoutGeckoBinaries'.
    def buildType = variant.buildType.name

    // It would be most natural for :geckoview to always include the Gecko
    // binaries, but that's difficult; see the notes in
    // mobile/android/gradle/with_gecko_binaries.gradle.  Instead we handle our
    // own Gecko binary inclusion.
    if (!buildType.equals('withoutGeckoBinaries')) {
        configureVariantWithGeckoBinaries(variant)
    }
}