build.gradle 7.46 KB
Newer Older
Geoffrey Métais's avatar
Geoffrey Métais committed
1 2 3
apply plugin: 'com.android.application'

android {
Geoffrey Métais's avatar
Geoffrey Métais committed
4 5 6 7 8 9 10
    packagingOptions {
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/armeabi/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/mips/libc++_shared.so'
Thomas Guillem's avatar
Thomas Guillem committed
11
        pickFirst 'lib/mips64/libc++_shared.so'
Geoffrey Métais's avatar
Geoffrey Métais committed
12 13
    }

14 15 16 17 18 19
    dexOptions {
        maxProcessCount 8
        javaMaxHeapSize "1g"
        preDexLibraries true
    }

20 21
    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion
Geoffrey Métais's avatar
Geoffrey Métais committed
22

23
    flavorDimensions "target", "abi"
24

Geoffrey Métais's avatar
Geoffrey Métais committed
25
    lintOptions {
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
26 27
        abortOnError false
        disable 'MissingTranslation', 'ExtraTranslation'
Geoffrey Métais's avatar
Geoffrey Métais committed
28 29
    }

30 31 32 33 34 35 36 37 38 39 40 41
    task luaPlaylistCopy(type: Copy) {
        from '../vlc/share/lua/playlist'
        into 'assets/lua/playlist'
        exclude '**/*.txt'
    }

    task luaMetaCopy(type: Copy) {
        from '../vlc/share/lua/meta'
        into 'assets/lua/meta'
        exclude '**/*.txt'
    }

42 43 44 45
    dataBinding {
        enabled = true
    }

Geoffrey Métais's avatar
Geoffrey Métais committed
46 47
    defaultConfig {
        applicationId "org.videolan.vlc"
48

49 50
        resValue "string", "build_time", buildTime()
        resValue "string", "build_host", hostName()
51
        resValue "string", "build_revision", revision()
Geoffrey Métais's avatar
Geoffrey Métais committed
52
        resValue "string", "build_vlc_revision", vlcRevision()
53

54 55 56 57
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
Geoffrey Métais's avatar
Geoffrey Métais committed
58

59
        tasks.whenTaskAdded { task ->
Thomas Guillem's avatar
Thomas Guillem committed
60
            if (task.name.startsWith('merge')) {
61 62 63 64 65
                task.dependsOn luaPlaylistCopy
                task.dependsOn luaMetaCopy
            }
        }

66
        //Set the build ABI according to build types only if not launched from compile.sh
67
        if (System.getenv('CLI') == null)
68 69
            tasks.whenTaskAdded { task ->
                if (task.name.startsWith('assemble')) {
Thomas Guillem's avatar
Thomas Guillem committed
70
                    if (task.name.endsWith('ARMv7Debug'))
71 72 73 74 75 76 77 78 79 80 81 82
                        task.dependsOn(":libvlc:buildDebugARMv7")
                    else if (task.name.endsWith('ARMv8Debug'))
                        task.dependsOn(":libvlc:buildDebugARM64")
                    else if (task.name.endsWith('X86Debug'))
                        task.dependsOn(":libvlc:buildDebugx86")
                    else if (task.name.endsWith('X86_64Debug'))
                        task.dependsOn(":libvlc:buildDebugx86_64")
                    else if (task.name.endsWith('MIPSDebug'))
                        task.dependsOn(":libvlc:buildDebugMIPS")
                    else if (task.name.endsWith('MIPS64Debug'))
                        task.dependsOn(":libvlc:buildDebugMIPS64")
                }
83
            }
Geoffrey Métais's avatar
Geoffrey Métais committed
84 85
    }

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
    signingConfigs {
        release {
            /*
            To set this properties, create file gradle.properties with these 3 props.
            e.g.
            keyStoreFile=/home/<username>/.android/debug.keystore
            storealias=androiddebugkey
            storepwd=android
             */
            storeFile file(keyStoreFile)
            keyAlias storealias
            if (System.getenv('PASSWORD_KEYSTORE') != null && !System.getenv('PASSWORD_KEYSTORE').isEmpty()){
                storePassword = System.getenv('PASSWORD_KEYSTORE')
                keyPassword = System.getenv('PASSWORD_KEYSTORE')
            } else {
                storePassword storepwd
                keyPassword storepwd
            }
        }
    }

Geoffrey Métais's avatar
Geoffrey Métais committed
107 108
    buildTypes {
        release {
109
            signingConfig null
110
            minifyEnabled true
111
            shrinkResources false
112
            proguardFile 'proguard.cfg'
Geoffrey Métais's avatar
Geoffrey Métais committed
113
        }
114 115 116 117
        signedRelease {
            initWith release
            signingConfig = signingConfigs.release
        }
Geoffrey Métais's avatar
Geoffrey Métais committed
118 119
        debug {
            applicationIdSuffix ".debug"
120
            jniDebuggable true
Geoffrey Métais's avatar
Geoffrey Métais committed
121
        }
Geoffrey Métais's avatar
Geoffrey Métais committed
122
    }
123
    productFlavors {
124 125 126 127 128 129 130 131 132
        vanilla {
            dimension "target"
            versionCode = 1
        }
        chrome {
            minSdkVersion 19
            dimension "target"
            versionCode = 2
        }
133
        ARMv7 {
134
            dimension "abi"
135 136 137
            versionCode = 4
        }
        x86 {
138
            dimension "abi"
139
            versionCode = 5
140
        }
141
        MIPS {
142
            dimension "abi"
143 144 145
            versionCode = 6
        }
        ARMv8 {
146
            dimension "abi"
147 148 149
            versionCode = 7
        }
        x86_64 {
150
            dimension "abi"
151 152 153
            versionCode = 8
        }
        MIPS64 {
154
            dimension "abi"
155 156 157 158 159 160
            versionCode = 9
        }
    }

    // make per-variant version code
    applicationVariants.all { variant ->
161 162 163 164 165 166 167 168 169 170
        // set the composite code
        variant.mergedFlavor.versionCode = variant.productFlavors.get(0).versionCode * 10000000 + defaultConfig.versionCode + variant.productFlavors.get(1).versionCode

        //Custom APK name
        variant.outputs.each { output ->
            def outputName = "VLC-Android-"
            if (variant.productFlavors.get(0).name != "vanilla")
                outputName += variant.productFlavors.get(0).name.toUpperCase() + "-"
            outputName += variant.versionName + "-" + variant.productFlavors.get(1).name + ".apk"
            output.outputFile = new File(output.outputFile.parentFile, outputName);
171
        }
172 173 174 175 176 177 178 179 180 181 182
    }

    sourceSets.main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
    }
183
    sourceSets.release {
184
        manifest.srcFile 'flavors/release/AndroidManifest.xml'
185
    }
186 187 188
    sourceSets.debug {
        res.srcDirs = ['flavors/debug/res']
    }
189 190 191
    sourceSets.test {
        java.srcDirs = ['test']
    }
192 193 194 195
    sourceSets.chrome {
        manifest.srcFile 'flavors/chrome/AndroidManifest.xml'
        res.srcDirs = ['flavors/chrome/res']
    }
Geoffrey Métais's avatar
Geoffrey Métais committed
196 197
}

198 199 200 201 202
task generateSources (type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}

Geoffrey Métais's avatar
Geoffrey Métais committed
203
dependencies {
204
    compile project(':libvlc')
205
    compile project(':medialibrary')
206
    compile project(':api')
Geoffrey Métais's avatar
Geoffrey Métais committed
207
    compile project(':axmlrpc')
208 209 210 211 212 213 214
    compile "com.android.support:recyclerview-v7:$rootProject.ext.appCompatVersion"
    compile "com.android.support:design:$rootProject.ext.appCompatVersion"
    compile "com.android.support:support-annotations:$rootProject.ext.appCompatVersion"
    compile "com.android.support:preference-v7:$rootProject.ext.appCompatVersion"
    compile "com.android.support:leanback-v17:$rootProject.ext.appCompatVersion"
    compile "com.android.support:preference-leanback-v17:$rootProject.ext.appCompatVersion"
    compile "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"
Geoffrey Métais's avatar
Geoffrey Métais committed
215
    testCompile 'junit:junit:4.12'
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
216
}
217

218
static def buildTime() {
219 220 221
    return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}

222
static def hostName() {
223
    return System.getProperty("user.name") + "@" + InetAddress.localHost.hostName
224 225 226 227 228 229 230 231
}

def revision() {
    def code = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = code
    }
Geoffrey Métais's avatar
Geoffrey Métais committed
232 233 234 235 236
    return code.toString()
}

def vlcRevision() {
    def vlc = new ByteArrayOutputStream()
237 238 239 240 241
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        workingDir '../vlc'
        standardOutput = vlc
    }
Geoffrey Métais's avatar
Geoffrey Métais committed
242
    return vlc.toString()
243
}