mirror of
https://github.com/jellyfin/jellyfin-androidtv.git
synced 2024-11-27 08:00:28 +00:00
Slightly change build files to be more consistent with Android mobile app.
- Updated apiclient - Changed how version is set - Updated getVersionCode function to support RC etc. - Updated Dependency Substitution code after review in Android mobile repo
This commit is contained in:
parent
964af83ace
commit
bda73e9386
@ -1,13 +1,13 @@
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("kotlin-android")
|
||||
id("kotlin-android-extensions")
|
||||
kotlin("android")
|
||||
kotlin("android.extensions")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion(29)
|
||||
// Explicitly specify ndk version for Azure
|
||||
// Can be removed when version 4.1.x of the Android Gradle plugin is relased
|
||||
// Can be removed when version 4.1.x of the Android Gradle plugin is released
|
||||
ndkVersion = "21.3.6528147"
|
||||
|
||||
defaultConfig {
|
||||
@ -16,8 +16,8 @@ android {
|
||||
targetSdkVersion(29)
|
||||
|
||||
// Release version
|
||||
versionCode = getVersionCode(project.version.toString()) ?: 1
|
||||
versionName = project.version.toString()
|
||||
versionName = project.getVersionName()
|
||||
versionCode = getVersionCode(versionName)
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@ -57,7 +57,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
// Jellyfin
|
||||
implementation("org.jellyfin.apiclient:android:0.7.2")
|
||||
implementation("org.jellyfin.apiclient:android:0.7.4")
|
||||
|
||||
// Kotlin
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
|
@ -11,11 +11,6 @@ buildscript {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
// Versioning
|
||||
allprojects {
|
||||
group = "org.jellyfin.apiclient"
|
||||
version = getProperty("jellyfin.version")?.removePrefix("v") ?: "DEV"
|
||||
}
|
||||
// Dependencies
|
||||
repositories {
|
||||
jcenter()
|
||||
|
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Get the versioncode for a given semver. Returns null if value is invalid.
|
||||
*
|
||||
* Sample output:
|
||||
* 0.0.0 -> 0
|
||||
* 1.1.1 -> 10101
|
||||
* 0.7.0 -> 700
|
||||
* 99.99.99 -> 999999
|
||||
*/
|
||||
fun getVersionCode(semver: String): Int? {
|
||||
val parts = semver.splitToSequence('.')
|
||||
.take(3)
|
||||
.mapNotNull { it.toIntOrNull() }
|
||||
.toList()
|
||||
|
||||
// Not a valid semver
|
||||
if (parts.size != 3) return null
|
||||
|
||||
var code = 0
|
||||
code += parts[0] * 10000 // Major (0-99)
|
||||
code += parts[1] * 100 // Minor (0-99)
|
||||
code += parts[2] // Patch (0-99)
|
||||
|
||||
return code
|
||||
}
|
65
buildSrc/src/main/kotlin/VersionUtils.kt
Normal file
65
buildSrc/src/main/kotlin/VersionUtils.kt
Normal file
@ -0,0 +1,65 @@
|
||||
import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* Get the version name from the current environment or use the fallback.
|
||||
* It will look for a environment variable called JELLYFIN_VERSION first.
|
||||
* Next it will look for a property called "jellyfin.version" and lastly it will use the fallback.
|
||||
* If the version in the environment starts with a "v" prefix it will be removed.
|
||||
*
|
||||
* Sample output:
|
||||
* v2.0.0 -> 2.0.0
|
||||
* null -> 0.0.0-dev.1 (unless different fallback set)
|
||||
*/
|
||||
fun Project.getVersionName(fallback: String = "0.0.0-dev.1") =
|
||||
getProperty("jellyfin.version")
|
||||
?.removePrefix("v")
|
||||
?: fallback
|
||||
|
||||
/**
|
||||
* Get the version code for a given semantic version.
|
||||
* Does not validate the input and thus will throw an exception when parts are missing.
|
||||
*
|
||||
* The pre-release part ("-rc.1", "-beta.1" etc.) defaults to 99
|
||||
*
|
||||
* Sample output:
|
||||
* MA.MI.PA-PR -> MAMIPAPR
|
||||
* 0.0.0 -> 99
|
||||
* 1.1.1 -> 1010199
|
||||
* 0.7.0 -> 70099
|
||||
* 99.99.99 -> 99999999
|
||||
* 2.0.0-rc.3 -> 2000003
|
||||
* 2.0.0 -> 2000099
|
||||
* 99.99.99-rc.1 -> 99999901
|
||||
*/
|
||||
fun getVersionCode(versionName: String): Int? {
|
||||
// Split to core and pre release parts with a default for pre release (null)
|
||||
val (versionCore, versionPreRelease) =
|
||||
when (val index = versionName.indexOf('-')) {
|
||||
// No pre-release part included
|
||||
-1 -> versionName to null
|
||||
// Pre-release part included
|
||||
else -> versionName.substring(0, index) to
|
||||
versionName.substring(index + 1, versionName.length)
|
||||
}
|
||||
|
||||
// Parse core part
|
||||
val (major, minor, patch) = versionCore
|
||||
.splitToSequence('.')
|
||||
.mapNotNull(String::toIntOrNull)
|
||||
.take(3)
|
||||
.toList()
|
||||
|
||||
// Parse pre release part (ignore type, only get the number)
|
||||
val buildVersion = versionPreRelease
|
||||
?.substringAfter('.')
|
||||
?.let(String::toIntOrNull)
|
||||
|
||||
// Build code
|
||||
var code = 0
|
||||
code += major * 1000000 // Major (0-99)
|
||||
code += minor * 10000 // Minor (0-99)
|
||||
code += patch * 100 // Patch (0-99)
|
||||
code += buildVersion ?: 99 // Pre release (0-99)
|
||||
|
||||
return code
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
import java.util.*
|
||||
|
||||
include(":app")
|
||||
|
||||
// Load properties from local.properties
|
||||
val properties = java.util.Properties().apply {
|
||||
val location = file("local.properties")
|
||||
val properties = Properties().apply {
|
||||
val location = File("local.properties")
|
||||
if (location.exists())
|
||||
load(location.inputStream())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user