3.4 KiB · text History cf032d1
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    alias(libs.plugins.kotlin.compose)
    alias(libs.plugins.kotlin.serialization)
}

// Bumped by hand; everything after it is generated, as in ../../clayman/android.
val baseVersion = "0.1.0"

val buildTimestamp: Long =
    (System.getenv("SOURCE_DATE_EPOCH") ?: System.getenv("BUILD_TIMESTAMP"))
        ?.toLongOrNull()
        ?: (System.currentTimeMillis() / 1000)

val appVersionName: String =
    System.getenv("RELEASE_VERSION")?.takeIf { it.isNotBlank() }
        ?: "$baseVersion-dev-$buildTimestamp"

android {
    namespace = "org.neiam.cartosnap.app"
    compileSdk = 34

    defaultConfig {
        applicationId = "org.neiam.cartosnap.app"
        minSdk = 26
        targetSdk = 34
        versionCode = (System.getenv("GITHUB_RUN_NUMBER") ?: "").toIntOrNull() ?: 1
        versionName = appVersionName

        // The server a fresh install signs in to (it can be changed), and the
        // host whose magic links open this app as verified App Links. The
        // server's /.well-known/assetlinks.json must list this build's
        // signing certificate (docs/app-login.md).
        val appLinksHost = "cs.neiam.org"
        manifestPlaceholders["appLinksHost"] = appLinksHost
        buildConfigField("String", "DEFAULT_SERVER", "\"https://$appLinksHost\"")
    }

    buildTypes {
        debug {
            // A dev server is plain http on the LAN or 10.0.2.2.
            manifestPlaceholders["cleartext"] = "true"
        }
        release {
            manifestPlaceholders["cleartext"] = "false"
            isMinifyEnabled = false
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_17
        targetCompatibility = JavaVersion.VERSION_17
    }
    buildFeatures {
        compose = true
        buildConfig = true
    }

    lint {
        // lintVital fails on JDK 25 with only the version string as its
        // message. Lint still runs on demand: ./gradlew :app:lint
        checkReleaseBuilds = false
    }
    packaging {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }
}

kotlin {
    compilerOptions {
        jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
    }
}

dependencies {
    implementation(libs.androidx.core.ktx)
    implementation(libs.androidx.lifecycle.runtime)
    implementation(libs.androidx.lifecycle.runtime.compose)
    implementation(libs.androidx.activity.compose)
    implementation(libs.androidx.security.crypto)
    // The upload queue: survives the app being closed, the phone rebooting
    // and the network coming and going.
    implementation(libs.androidx.work.runtime)

    implementation(platform(libs.compose.bom))
    implementation(libs.compose.ui)
    implementation(libs.compose.ui.tooling.preview)
    implementation(libs.compose.material3)
    implementation(libs.compose.material.icons)
    debugImplementation(libs.compose.ui.tooling)

    implementation(libs.kotlinx.coroutines)
    implementation(libs.kotlinx.serialization.json)
    implementation(libs.okhttp)
    implementation(libs.coil.compose)
    // Custom Tabs: SSO sign-in runs in the system browser, never a WebView.
    implementation(libs.androidx.browser)

    testImplementation(libs.junit)
}