apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' android { packagingOptions { exclude 'META-INF/main.kotlin_module' } dexOptions { maxProcessCount 8 javaMaxHeapSize "2g" preDexLibraries true } compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion flavorDimensions "target", "abi" lintOptions { abortOnError false disable 'MissingTranslation', 'ExtraTranslation' } 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' } dataBinding { enabled = true } defaultConfig { applicationId "org.videolan.vlc" resValue "string", "build_time", buildTime() resValue "string", "build_host", hostName() resValue "string", "build_revision", revision() resValue "string", "build_vlc_revision", vlcRevision() minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode rootProject.ext.versionCode versionName rootProject.ext.versionName tasks.whenTaskAdded { task -> if (task.name.startsWith('merge')) { task.dependsOn luaPlaylistCopy task.dependsOn luaMetaCopy } } } signingConfigs { release { /* To set this properties, create file gradle.properties with these 3 props. e.g. keyStoreFile=/home//.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 } } } buildTypes { release { signingConfig null minifyEnabled true shrinkResources false proguardFile 'proguard.cfg' } signedRelease { initWith release signingConfig = signingConfigs.release matchingFallbacks = ['release'] } debug { applicationIdSuffix ".debug" jniDebuggable true } } productFlavors { vanilla { dimension "target" versionCode = 1 } chrome { minSdkVersion 19 dimension "target" versionCode = 2 } ARMv7 { dimension "abi" versionCode = 4 } x86 { dimension "abi" versionCode = 5 } MIPS { dimension "abi" versionCode = 6 } ARMv8 { dimension "abi" versionCode = 7 } x86_64 { dimension "abi" versionCode = 8 } MIPS64 { dimension "abi" versionCode = 9 } } // make per-variant version code applicationVariants.all { variant -> def generatedCode = variant.productFlavors.get(0).versionCode * 10000000 + defaultConfig.versionCode + variant.productFlavors.get(1).versionCode variant.mergedFlavor.versionCode = generatedCode //Custom APK name variant.outputs.all { 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" outputFileName = outputName output.processManifest.doLast { // set the composite code String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml" def manifestContent = file(manifestPath).getText() manifestContent = manifestContent.replace('android:versionCode="1"', String.format('android:versionCode="%s"', generatedCode)) file(manifestPath).write(manifestContent) } } } sourceSets.main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } sourceSets.release { manifest.srcFile 'flavors/release/AndroidManifest.xml' } sourceSets.debug { res.srcDirs = ['flavors/debug/res'] } sourceSets.test { java.srcDirs = ['test'] } sourceSets.chrome { manifest.srcFile 'flavors/chrome/AndroidManifest.xml' res.srcDirs = ['flavors/chrome/res'] } } task generateSources (type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } dependencies { implementation project(':libvlc') implementation project(':medialibrary') implementation project(':api') implementation project(':axmlrpc') // AppCompat kapt 'com.android.databinding:compiler:3.0.1' implementation "com.android.support:recyclerview-v7:$rootProject.ext.appCompatVersion" implementation "com.android.support:design:$rootProject.ext.appCompatVersion" implementation "com.android.support:support-annotations:$rootProject.ext.appCompatVersion" implementation "com.android.support:preference-v7:$rootProject.ext.appCompatVersion" implementation "com.android.support:leanback-v17:$rootProject.ext.appCompatVersion" implementation "com.android.support:preference-leanback-v17:$rootProject.ext.appCompatVersion" implementation "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion" testImplementation 'junit:junit:4.12' // Kotlin implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" kapt "com.android.databinding:compiler:$rootProject.ext.android_plugin_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.ext.kotlinx_version" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlinx_version" } kotlin { experimental { coroutines "enable" } } static def buildTime() { return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC")) } static def hostName() { return System.getProperty("user.name") + "@" + InetAddress.localHost.hostName } def revision() { def code = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--short', 'HEAD' standardOutput = code } return code.toString() } def vlcRevision() { def vlc = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--short', 'HEAD' workingDir '../vlc' standardOutput = vlc } return vlc.toString() }