mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-22 02:01:08 +07:00
Refactoring build
Move to gradle kotlin DSL Use gradle version catalog All android build parameters are set via cmake files Use gradle abi split to build APKs Improve local development in the android project folder
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
[versions]
|
||||
agp = "8.1.3"
|
||||
kotlin = "1.9.20"
|
||||
androidx-core = "1.12.0"
|
||||
androidx-appcompat = "1.6.1"
|
||||
androidx-camera = "1.2.3"
|
||||
androidx-security-crypto = "1.1.0-alpha06"
|
||||
kotlinx-coroutines = "1.7.3"
|
||||
google-mlkit = "17.2.0"
|
||||
|
||||
[libraries]
|
||||
androidx-core = { module = "androidx.core:core-ktx", version.ref = "androidx-core" }
|
||||
androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "androidx-appcompat" }
|
||||
androidx-camera-core = { module = "androidx.camera:camera-core", version.ref = "androidx-camera" }
|
||||
androidx-camera-camera2 = { module = "androidx.camera:camera-camera2", version.ref = "androidx-camera" }
|
||||
androidx-camera-lifecycle = { module = "androidx.camera:camera-lifecycle", version.ref = "androidx-camera" }
|
||||
androidx-camera-view = { module = "androidx.camera:camera-view", version.ref = "androidx-camera" }
|
||||
androidx-security-crypto = { module = "androidx.security:security-crypto-ktx", version.ref = "androidx-security-crypto" }
|
||||
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines" }
|
||||
google-mlkit = { module = "com.google.mlkit:barcode-scanning", version.ref = "google-mlkit" }
|
||||
# todo: remove after finish refactoring
|
||||
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version = "2.1.4" }
|
||||
|
||||
[bundles]
|
||||
androidx-camera = [
|
||||
"androidx-camera-core",
|
||||
"androidx-camera-lifecycle",
|
||||
"androidx-camera-view",
|
||||
"androidx-camera-camera2"
|
||||
]
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
android-library = { id = "com.android.library", version.ref = "agp" }
|
||||
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
@@ -0,0 +1,33 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
register("settingsGradlePropertyDelegate") {
|
||||
id = "settings-property-delegate"
|
||||
implementationClass = "SettingsPropertyDelegate"
|
||||
}
|
||||
|
||||
register("projectGradlePropertyDelegate") {
|
||||
id = "property-delegate"
|
||||
implementationClass = "ProjectPropertyDelegate"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stop Gradle running by androiddeployqt
|
||||
gradle.taskGraph.whenReady {
|
||||
if (providers.environmentVariable("ANDROIDDEPLOYQT_RUN").isPresent
|
||||
&& !providers.systemProperty("explicitRun").isPresent) {
|
||||
tasks.forEach { it.enabled = false }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.util.Properties
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
import kotlin.reflect.KProperty
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.initialization.Settings
|
||||
import org.gradle.api.provider.ProviderFactory
|
||||
|
||||
private fun localProperties(rootDir: File) = Properties().apply {
|
||||
val localProperties = File(rootDir, "local.properties")
|
||||
if (localProperties.isFile) {
|
||||
InputStreamReader(FileInputStream(localProperties), Charsets.UTF_8).use {
|
||||
load(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PropertyDelegate(
|
||||
rootDir: File,
|
||||
private val providers: ProviderFactory,
|
||||
private val localProperties: Properties = localProperties(rootDir)
|
||||
) : ReadOnlyProperty<Any?, String> {
|
||||
override fun getValue(thisRef: Any?, property: KProperty<*>): String =
|
||||
providers.gradleProperty(property.name).orNull ?: localProperties.getProperty(property.name)
|
||||
}
|
||||
|
||||
private lateinit var settingsPropertyDelegate: ReadOnlyProperty<Any?, String>
|
||||
private lateinit var projectPropertyDelegate: ReadOnlyProperty<Any?, String>
|
||||
|
||||
class SettingsPropertyDelegate : Plugin<Settings> {
|
||||
override fun apply(settings: Settings) {
|
||||
settingsPropertyDelegate = PropertyDelegate(settings.rootDir, settings.providers)
|
||||
}
|
||||
}
|
||||
|
||||
class ProjectPropertyDelegate : Plugin<Project> {
|
||||
override fun apply(project: Project) {
|
||||
projectPropertyDelegate = PropertyDelegate(project.rootDir, project.providers)
|
||||
}
|
||||
}
|
||||
|
||||
val Settings.gradleProperties: ReadOnlyProperty<Any?, String>
|
||||
get() = settingsPropertyDelegate
|
||||
|
||||
val Project.gradleProperties: ReadOnlyProperty<Any?, String>
|
||||
get() = projectPropertyDelegate
|
||||
Reference in New Issue
Block a user