summaryrefslogtreecommitdiffstats
path: root/mobile/android/bouncer/build.gradle
blob: 210aa7ece004b238ba52d691aedb97cfa66bb5c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
buildDir "${topobjdir}/gradle/build/mobile/android/bouncer"

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion mozconfig.substs.ANDROID_BUILD_TOOLS_VERSION

    defaultConfig {
        targetSdkVersion 23
        minSdkVersion 15 
        applicationId mozconfig.substs.ANDROID_PACKAGE_NAME
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
 
    dexOptions {
        javaMaxHeapSize "2g"
    }

    lintOptions {
        abortOnError false
    }

    buildTypes {
        release {
            minifyEnabled false
        }
    }

    sourceSets {
        main {
            manifest.srcFile "${topobjdir}/mobile/android/bouncer/AndroidManifest.xml"
            assets {
                if (mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY) {
                    srcDir "${mozconfig.substs.MOZ_ANDROID_DISTRIBUTION_DIRECTORY}/assets"
                }
            }
            java {
                srcDir 'java'
            }
            res {
                srcDir "${topsrcdir}/${mozconfig.substs.MOZ_BRANDING_DIRECTORY}/res" // For the icon.
                srcDir 'res'
            }
        }
    }
}

task generateCodeAndResources(type:Exec) {
    workingDir "${topobjdir}"

    commandLine mozconfig.substs.GMAKE
    args '-C'
    args "${topobjdir}/mobile/android/bouncer"
    args 'gradle-targets'

    // Only show the output if something went wrong.
    ignoreExitValue = true
    standardOutput = new ByteArrayOutputStream()
    errorOutput = standardOutput
    doLast {
        if (execResult.exitValue != 0) {
            throw new GradleException("Process '${commandLine}' finished with non-zero exit value ${execResult.exitValue}:\n\n${standardOutput.toString()}")
        }
    }
}

afterEvaluate {
    android.applicationVariants.all {
        preBuild.dependsOn generateCodeAndResources
    }
}