You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

310 lines
12 KiB

plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.devtools.ksp'
id 'kotlin-parcelize'
}
android {
dataBinding {
enabled = true
}
packagingOptions {
jniLibs {
pickFirsts += ['**/*.so']
}
}
defaultConfig {
resValue "string", "build_time", buildTime(project)
resValue "string", "build_host", hostName(project)
resValue "string", "build_revision", revision()
resValue "string", "changelog", changelog()
resValue "string", "dav1d_version", dav1dVersion()
resValue 'string', 'tv_provider_authority', "${rootProject.ext.appId}.tv"
buildConfigField 'String', 'LIBVLC_VERSION', "\"${rootProject.ext.libvlcVersion}\""
buildConfigField 'String', 'ML_VERSION', "\"${rootProject.ext.medialibraryVersion}\""
buildConfigField "String", "APP_ID", "\"${rootProject.ext.appId}\""
buildConfigField 'int', 'VLC_VERSION_CODE', "${rootProject.ext.versionCode}"
buildConfigField 'String', 'VLC_VERSION_NAME', "\"${rootProject.ext.versionName}\""
buildConfigField 'String[]', 'TRANSLATION_ARRAY', generateTranslation()
buildConfigField 'int', 'VLC_MAJOR_VERSION', "${rootProject.ext.vlcMajorVersion}"
testInstrumentationRunner "org.videolan.vlc.MultidexTestRunner"
// The following argument makes the Android Test Orchestrator run its
// "pm clear" command after each test invocation. This command ensures
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
compileSdk = rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
vectorDrawables.useSupportLibrary = true
}
testOptions {
animationsDisabled = true
execution 'ANDROIDX_TEST_ORCHESTRATOR'
unitTests {
includeAndroidResources = true
}
unitTests.all {
jvmArgs '-noverify'
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
}
buildTypes {
release {
proguardFile 'proguard.cfg'
buildConfigField "boolean", "BETA", isBeta()
resValue 'string', 'benchmark_package_name', 'org.videolan.vlcbenchmark'
}
debug {
buildConfigField "boolean", "BETA", "false"
resValue 'string', 'benchmark_package_name', 'org.videolan.vlcbenchmark.debug'
buildConfigField "String", "APP_ID", "\"${rootProject.ext.appId}.debug\""
resValue 'string', 'tv_provider_authority', "${rootProject.ext.appId}.debug.tv"
buildConfigField "boolean", "NO_TV", "false"
multiDexEnabled = true
}
vlcBundle {
initWith release
matchingFallbacks = ['release']
}
signedRelease {
initWith release
matchingFallbacks = ['release']
}
dev {
initWith debug
matchingFallbacks = ['debug']
}
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = rootProject.ext.vlcMajorVersion == 4 ? ['src', 'vlc4/src'] : ['src', 'vlc3/src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
sourceSets.debug {
res.srcDirs = ['flavors/debug/res']
assets.srcDirs = ['flavors/debug/assets']
}
sourceSets.dev {
res.srcDirs = ['flavors/debug/res']
assets.srcDirs = ['flavors/debug/assets']
}
sourceSets.test {
java.srcDirs = ['test', 'test-common']
assets.srcDirs = ['flavors/debug/assets']
}
sourceSets.androidTest {
java.srcDirs = ['androidTest', 'test-common']
assets.srcDirs = ['flavors/debug/assets']
assets.srcDirs += files("$projectDir/assets/schemas".toString())
}
namespace = 'org.videolan.vlc'
buildFeatures {
renderScript = true
aidl = true
buildConfig = true
}
}
def generateTranslation() {
def foundLocales = new StringBuilder()
foundLocales.append("new String[]{\"")
def emptyList = []
fileTree("../resources/src/main/res").visit { FileVisitDetails details ->
// println 'details: ' + details
if (details.file.path.endsWith("strings.xml")) {
def languageCode = details.file.parentFile.name.replaceAll('values-', '').replaceAll('-r', '-')
languageCode = (languageCode == "values") ? "en" : languageCode
// println 'adding ' + languageCode + ' strings'
emptyList.add(languageCode)
}
}
emptyList.sort()
foundLocales.append(emptyList.join("\",\""))
foundLocales.append("\"}")
def foundLocalesString = foundLocales.toString()
return foundLocalesString
}
task generateSources(type: Jar) {
from android.sourceSets.main.java.srcDirs
}
dependencies {
devApi project(':libvlcjni:libvlc')
devApi project(':medialibrary')
debugApi "org.videolan.android:libvlc-all:$rootProject.ext.libvlcVersion"
debugApi "org.videolan.android:medialibrary-all:$rootProject.ext.medialibraryVersion"
releaseApi "org.videolan.android:libvlc-all:$rootProject.ext.libvlcVersion"
releaseApi "org.videolan.android:medialibrary-all:$rootProject.ext.medialibraryVersion"
signedReleaseApi "org.videolan.android:libvlc-all:$rootProject.ext.libvlcVersion"
signedReleaseApi "org.videolan.android:medialibrary-all:$rootProject.ext.medialibraryVersion"
api project(':application:tools')
api project(':application:resources')
api project(':application:mediadb')
api project(':application:live-plot-graph')
// AppCompat
api "androidx.activity:activity-ktx:$rootProject.ext.androidxActivityVersion"
api "androidx.fragment:fragment-ktx:$rootProject.ext.androidxFragmentVersion"
api "androidx.recyclerview:recyclerview:$rootProject.ext.androidxRecyclerviewVersion"
api "com.google.android.material:material:$rootProject.ext.androidxMaterialVersion"
api "androidx.annotation:annotation:$rootProject.ext.androidxAnnotationVersion"
api "androidx.constraintlayout:constraintlayout:$rootProject.ext.constraintLayoutVersion"
api "androidx.viewpager2:viewpager2:$rootProject.ext.viewPager2Version"
api 'androidx.multidex:multidex:2.0.1'
api "androidx.lifecycle:lifecycle-process:$rootProject.ext.lifecycleVersion"
api "androidx.lifecycle:lifecycle-service:$rootProject.ext.lifecycleVersion"
api "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.ext.lifecycleVersion"
api "androidx.lifecycle:lifecycle-runtime-ktx:$rootProject.ext.lifecycleVersion"
api "androidx.lifecycle:lifecycle-livedata-ktx:$rootProject.ext.lifecycleVersion"
api "androidx.lifecycle:lifecycle-common-java8:$rootProject.ext.lifecycleVersion"
api "androidx.room:room-runtime:$rootProject.ext.roomVersion"
api "androidx.window:window:$rootProject.ext.windowVersion"
api "androidx.media:media:$rootProject.ext.mediaVersion"
api 'androidx.gridlayout:gridlayout:1.0.0'
api "androidx.car.app:app:$rootProject.ext.carVersion"
ksp ("org.xerial:sqlite-jdbc:jdbcVersion")
ksp("androidx.room:room-compiler:$rootProject.ext.roomVersion")
api "androidx.paging:paging-runtime-ktx:$rootProject.ext.pagingVersion"
//TV
api "androidx.leanback:leanback:$rootProject.ext.androidxLeanbackVersion"
api "androidx.leanback:leanback-preference:$rootProject.ext.androidxLeanbackVersion"
api "androidx.tvprovider:tvprovider:$rootProject.ext.androidxLeanbackVersion"
// Kotlin
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.ext.kotlinx_version"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.ext.kotlinx_version"
implementation 'nl.dionsegijn:konfetti-xml:2.0.4'
implementation 'com.google.zxing:core:3.4.0'
implementation "androidx.palette:palette-ktx:1.0.0"
implementation 'com.jaredrummler:colorpicker:1.1.0'
// Tests
androidTestImplementation "androidx.test.espresso:espresso-contrib:$rootProject.espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-intents:$rootProject.espressoVersion"
testImplementation "junit:junit:$rootProject.ext.junitVersion"
androidTestImplementation "androidx.room:room-testing:$rootProject.ext.roomVersion"
testImplementation "androidx.arch.core:core-testing:$rootProject.ext.archVersion"
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.ext.archVersion"
androidTestImplementation "androidx.test.ext:junit:$rootProject.ext.junitExtVersion"
androidTestUtil "androidx.test:orchestrator:$rootProject.ext.orchestrator"
testImplementation "androidx.test:core:$rootProject.ext.testCore"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$rootProject.ext.kotlinx_version"
testImplementation "org.mockito:mockito-core:$rootProject.ext.mockito"
testImplementation "io.mockk:mockk:$rootProject.ext.mockk"
testImplementation "org.powermock:powermock-api-mockito2:$rootProject.ext.powerMock"
testImplementation "org.powermock:powermock-module-junit4:$rootProject.ext.powerMock"
testImplementation "com.jraska.livedata:testing-ktx:$rootProject.ext.livedataTest"
testImplementation "org.robolectric:robolectric:$rootProject.ext.robolectric"
androidTestImplementation "androidx.test:rules:$rootProject.ext.testCore"
androidTestImplementation 'com.jraska:falcon:2.2.0'
androidTestImplementation 'tools.fastlane:screengrab:2.1.0'
if (project.hasProperty('leakCanaryEnabled') && project.getProperty('leakCanaryEnabled')) {
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
devImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
}
}
static def buildTime(project) {
if (project.hasProperty('forceDeterministic')) {
def code = new ByteArrayOutputStream()
project.exec {
commandLine 'git', 'show', '--no-patch', '--format=%cd' , '--date=format-local:%Y-%m-%d'
standardOutput = code
}
return code.toString()
}
return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC"))
}
static def hostName(project) {
if (project.hasProperty('forceDeterministic')) {
if (project.hasProperty('forcedHostName')) {
return project.findProperty("forcedHostName")
}
return 'Unknown'
}
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 dav1dVersion() {
def code = "0.0.0"
File dav1dContribFile = file('../../libvlcjni/vlc/contrib/src/dav1d/rules.mak')
if (dav1dContribFile.exists()) {
dav1dContribFile.readLines().each {
if (it.contains('DAV1D_VERSION := ')) {
code = it.replaceAll("DAV1D_VERSION := ", "")
return
}
}
}
return code
}
/**
* Generate a changelog string from the NEWS file
* @return a string containing the latest changelog entry
*/
def changelog() {
def newsFile = new File("NEWS")
def line, output = "", started = false
if (newsFile.exists()) {
newsFile.withReader { reader ->
while ((line = reader.readLine()) != null) {
if (started && !line?.trim()) break
if (started) {
if (output != "") output += "\\n"
output += line.trim().replaceAll(/(@|'|"|\\/|\(|\)|=|\?)/, /\\$0/)
}
if (line.contains("---")) started = true
}
}
}
return output
}
def isBeta() {
def versionNameLower = versionName.toLowerCase()
return (versionNameLower.contains("beta") || versionNameLower.contains("rc") || versionNameLower.contains("alpha") || versionNameLower.contains("dev")).toString()
}