Files
bgclock/android/app/build.gradle.kts
T
hansdezwartandClaude Opus 5 bf3f565dd0 Release 1.3
versionCode 4. public_html/ changed, so the service worker cache goes to
bgclock-v19 — without it an installed web user would keep serving the old page
from cache indefinitely.

The five store screenshots are untouched: the ring only exists while a finger
is on the button, and none of them shows that.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 14:51:14 +02:00

78 lines
2.1 KiB
Kotlin

import javax.inject.Inject
plugins {
id("com.android.application")
}
android {
namespace = "nl.hansdezwart.bgclock"
compileSdk = 36
defaultConfig {
applicationId = "nl.hansdezwart.bgclock"
minSdk = 26
targetSdk = 36
versionCode = 4
versionName = "1.3"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildTypes {
release {
isMinifyEnabled = false
}
}
}
/**
* The web app is not copied into the repo — it is read out of public_html at
* build time, so the browser version and the app version cannot drift.
*
* sw.js is left behind on purpose: it is cache-first, and a service-worker cache
* outlives an app upgrade, so it would go on serving the old index.html with no
* way to clear it. Without the file the registration fails into its own .catch,
* and the APK is the cache instead.
*/
abstract class SyncWebAssets : DefaultTask() {
@get:InputDirectory
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val source: DirectoryProperty
@get:OutputDirectory
abstract val outputDir: DirectoryProperty
@get:Inject
abstract val fs: FileSystemOperations
@TaskAction
fun run() {
fs.sync {
from(source) { exclude("sw.js") }
into(outputDir)
}
}
}
val webAssets = tasks.register<SyncWebAssets>("syncWebAssets") {
source.fileValue(rootProject.file("../public_html"))
}
// the Variant API, not sourceSets.assets.srcDir: AGP 9 refuses a Provider there
// because it can't tell generated from static, and this way the task dependency
// is carried automatically
androidComponents {
onVariants { variant ->
variant.sources.assets?.addGeneratedSourceDirectory(webAssets, SyncWebAssets::outputDir)
}
}
dependencies {
// the only dependency: WebViewAssetLoader, which serves the assets over a
// real https origin so they count as a secure context
implementation("androidx.webkit:webkit:1.16.0")
}