Vectrum
Sign In
55 lines · 1.9 KB · Kotlin
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.compose)
    alias(libs.plugins.kotlin.serialization)
}

// The app carries the desktop app's version from Cargo.toml: 0.1.9-local is
// versionName 0.1.9-local and versionCode 1009 (major * 1000000 + minor * 1000 + patch).
val desktopVersion: String = providers.fileContents(rootProject.layout.projectDirectory.file("../Cargo.toml"))
    .asText.get().lineSequence()
    .firstNotNullOf { Regex("""^version\s*=\s*"(.+)"""").find(it)?.groupValues?.get(1) }
val desktopVersionCode: Int = desktopVersion.substringBefore('-').substringBefore('+').split('.').map(String::toInt)
    .let { (major, minor, patch) ->
        require(minor < 1000 && patch < 1000) { "Version $desktopVersion doesn't fit a versionCode" }
        major * 1_000_000 + minor * 1_000 + patch
    }

android {
    namespace = "cc.vectrum.code"
    compileSdk = 37

    defaultConfig {
        applicationId = "cc.vectrum.code"
        minSdk = 29
        targetSdk = 37
        versionCode = desktopVersionCode
        versionName = desktopVersion
    }

    buildFeatures { compose = true }

    testOptions { unitTests.isReturnDefaultValues = true }

    buildTypes {
        release {
            isMinifyEnabled = true
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
            // Signed with the debug key until there's an upload key.
            signingConfig = signingConfigs.getByName("debug")
        }
    }
}

dependencies {
    implementation(libs.androidx.activity.compose)
    implementation(libs.compose.runtime)
    implementation(libs.compose.foundation)
    implementation(libs.compose.ui)
    implementation(libs.compose.ui.text)
    implementation(libs.coroutines.android)
    implementation(libs.serialization.json)
    implementation(libs.okhttp)
    implementation(libs.code.scanner)
    testImplementation(libs.junit)
}