chore(stage-pocket): migrate gradle scripts to kotlin dsl

This commit is contained in:
LemonNeko
2026-03-31 16:25:21 +08:00
parent d391fad92c
commit 7811284fcc
7 changed files with 114 additions and 86 deletions
@@ -1,58 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'org.jetbrains.kotlin.android'
android {
namespace = "ai.moeru.airi_pocket"
compileSdk = rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "ai.moeru.airi_pocket"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
kotlinOptions {
jvmTarget = '21'
}
}
repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
@@ -0,0 +1,76 @@
val androidMinSdk = rootProject.extra["minSdkVersion"] as Int
val androidCompileSdk = rootProject.extra["compileSdkVersion"] as Int
val androidTargetSdk = rootProject.extra["targetSdkVersion"] as Int
val androidxAppCompatVersion = rootProject.extra["androidxAppCompatVersion"] as String
val androidxCoordinatorLayoutVersion = rootProject.extra["androidxCoordinatorLayoutVersion"] as String
val coreSplashScreenVersion = rootProject.extra["coreSplashScreenVersion"] as String
val junitVersion = rootProject.extra["junitVersion"] as String
val androidxJunitVersion = rootProject.extra["androidxJunitVersion"] as String
val androidxEspressoCoreVersion = rootProject.extra["androidxEspressoCoreVersion"] as String
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "ai.moeru.airi_pocket"
compileSdk = androidCompileSdk
defaultConfig {
applicationId = "ai.moeru.airi_pocket"
minSdk = androidMinSdk
targetSdk = androidTargetSdk
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro",
)
}
}
kotlinOptions {
jvmTarget = "21"
}
}
repositories {
flatDir {
dirs("../capacitor-cordova-android-plugins/src/main/libs", "libs")
}
}
dependencies {
implementation(fileTree(mapOf("include" to listOf("*.jar"), "dir" to "libs")))
implementation("androidx.appcompat:appcompat:$androidxAppCompatVersion")
implementation("androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion")
implementation("androidx.core:core-splashscreen:$coreSplashScreenVersion")
implementation(project(":capacitor-android"))
testImplementation("junit:junit:$junitVersion")
androidTestImplementation("androidx.test.ext:junit:$androidxJunitVersion")
androidTestImplementation("androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion")
implementation(project(":capacitor-cordova-android-plugins"))
}
apply(from = "capacitor.build.gradle")
try {
val servicesJson = file("google-services.json")
if (servicesJson.readText().isNotBlank()) {
apply(plugin = "com.google.gms.google-services")
}
} catch (error: Exception) {
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
@@ -1,22 +1,24 @@
import org.gradle.api.tasks.Delete
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.13.0'
classpath 'com.google.gms:google-services:4.4.4'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.21'
classpath("com.android.tools.build:gradle:8.13.0")
classpath("com.google.gms:google-services:4.4.4")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.21")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply from: "variables.gradle"
apply(from = "variables.gradle.kts")
allprojects {
repositories {
@@ -25,6 +27,6 @@ allprojects {
}
}
task clean(type: Delete) {
delete rootProject.buildDir
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}
@@ -1,5 +0,0 @@
include ':app'
include ':capacitor-cordova-android-plugins'
project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/')
apply from: 'capacitor.settings.gradle'
@@ -0,0 +1,13 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
include(":app")
include(":capacitor-cordova-android-plugins")
project(":capacitor-cordova-android-plugins").projectDir = file("./capacitor-cordova-android-plugins/")
apply(from = "capacitor.settings.gradle")
@@ -1,16 +0,0 @@
ext {
minSdkVersion = 24
compileSdkVersion = 36
targetSdkVersion = 36
androidxActivityVersion = '1.11.0'
androidxAppCompatVersion = '1.7.1'
androidxCoordinatorLayoutVersion = '1.3.0'
androidxCoreVersion = '1.17.0'
androidxFragmentVersion = '1.8.9'
coreSplashScreenVersion = '1.2.0'
androidxWebkitVersion = '1.14.0'
junitVersion = '4.13.2'
androidxJunitVersion = '1.3.0'
androidxEspressoCoreVersion = '3.7.0'
cordovaAndroidVersion = '14.0.1'
}
@@ -0,0 +1,16 @@
extra.apply {
set("minSdkVersion", 24)
set("compileSdkVersion", 36)
set("targetSdkVersion", 36)
set("androidxActivityVersion", "1.11.0")
set("androidxAppCompatVersion", "1.7.1")
set("androidxCoordinatorLayoutVersion", "1.3.0")
set("androidxCoreVersion", "1.17.0")
set("androidxFragmentVersion", "1.8.9")
set("coreSplashScreenVersion", "1.2.0")
set("androidxWebkitVersion", "1.14.0")
set("junitVersion", "4.13.2")
set("androidxJunitVersion", "1.3.0")
set("androidxEspressoCoreVersion", "3.7.0")
set("cordovaAndroidVersion", "14.0.1")
}