From 16691b174b9e153eab218cd7ee77844dd1cb22e6 Mon Sep 17 00:00:00 2001 From: Shingyx Date: Sun, 24 Aug 2025 11:36:22 +1000 Subject: [PATCH 1/3] plugins blocks --- app/build.gradle | 10 ++++++---- build.gradle | 26 ++++---------------------- settings.gradle | 23 +++++++++++++++++++++++ 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ad7cf20..8a75b7c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,9 @@ -apply plugin: 'com.android.application' -apply plugin: 'com.google.android.gms.oss-licenses-plugin' -apply plugin: "com.ncorti.ktfmt.gradle" -apply plugin: 'kotlin-android' +plugins { + id 'com.android.application' + id 'com.google.android.gms.oss-licenses-plugin' + id 'com.ncorti.ktfmt.gradle' + id 'kotlin-android' +} def keystorePropertiesFile = rootProject.file("keystore.properties") def keystoreProperties = new Properties() diff --git a/build.gradle b/build.gradle index 617aa33..4c60973 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +1,9 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { ext.kotlin_version = '2.2.0' - repositories { - google() - mavenCentral() - maven { - url = "https://plugins.gradle.org/m2/" - } - } - dependencies { - classpath 'com.android.tools.build:gradle:8.12.1' - classpath 'com.google.android.gms:oss-licenses-plugin:0.10.7' - classpath "com.ncorti.ktfmt.gradle:plugin:0.23.0" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } } -allprojects { - repositories { - google() - mavenCentral() - } +plugins { + id 'com.android.application' version '8.12.1' apply false + id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false + id 'com.ncorti.ktfmt.gradle' version '0.23.0' apply false } diff --git a/settings.gradle b/settings.gradle index e7b4def..9bff6c1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,24 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") { + useModule("com.google.android.gms:oss-licenses-plugin:0.10.7") + } + } + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + include ':app' From 48d37dcc64f750f4f107f288a4be5f09c0a52895 Mon Sep 17 00:00:00 2001 From: Shingyx Date: Sun, 24 Aug 2025 12:12:22 +1000 Subject: [PATCH 2/3] kts --- app/build.gradle | 67 -------------------------------------------- app/build.gradle.kts | 67 ++++++++++++++++++++++++++++++++++++++++++++ build.gradle | 9 ------ build.gradle.kts | 5 ++++ settings.gradle | 24 ---------------- settings.gradle.kts | 24 ++++++++++++++++ 6 files changed, 96 insertions(+), 100 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 8a75b7c..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,67 +0,0 @@ -plugins { - id 'com.android.application' - id 'com.google.android.gms.oss-licenses-plugin' - id 'com.ncorti.ktfmt.gradle' - id 'kotlin-android' -} - -def keystorePropertiesFile = rootProject.file("keystore.properties") -def keystoreProperties = new Properties() -try { - keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) -} catch (FileNotFoundException ignored) { - logger.warn('keystore.properties not found') -} - -android { - namespace = 'com.github.shingyx.boomswitch' - signingConfigs { - release { - storeFile = rootProject.file(keystoreProperties['storeFile'] ?: "default.jks") - storePassword = keystoreProperties['storePassword'] - keyAlias = keystoreProperties['keyAlias'] - keyPassword = keystoreProperties['keyPassword'] - } - } - compileSdk = 36 - defaultConfig { - applicationId = "com.github.shingyx.boomswitch" - minSdk = 23 - targetSdk = 36 - versionCode = 13 - versionName = "1.9" - } - buildTypes { - debug { - applicationIdSuffix = ".dev" - versionNameSuffix = "-dev" - } - release { - minifyEnabled = true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt') - signingConfig = signingConfigs.release - } - } - buildFeatures { - buildConfig = true - viewBinding = true - } - kotlin { - jvmToolchain(21) - } -} - -ktfmt { - googleStyle() -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.7.1' - implementation 'androidx.constraintlayout:constraintlayout:2.2.1' - implementation 'com.google.android.gms:play-services-oss-licenses:17.2.2' - implementation 'com.google.android.material:material:1.12.0' - implementation 'com.jakewharton.timber:timber:5.0.1' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2' -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..332d011 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,67 @@ +import java.io.FileInputStream +import java.io.FileNotFoundException +import java.util.Properties + +plugins { + id("com.android.application") + id("com.google.android.gms.oss-licenses-plugin") + id("com.ncorti.ktfmt.gradle") + id("kotlin-android") +} + +val keystorePropertiesFile = rootProject.file("keystore.properties") +val keystoreProperties = Properties() + +try { + keystoreProperties.load(FileInputStream(keystorePropertiesFile)) +} catch (_: FileNotFoundException) { + logger.warn("keystore.properties not found") +} + +android { + namespace = "com.github.shingyx.boomswitch" + signingConfigs { + create("release") { + storeFile = rootProject.file(keystoreProperties.getProperty("storeFile") ?: "default.jks") + storePassword = keystoreProperties.getProperty("storePassword") + keyAlias = keystoreProperties.getProperty("keyAlias") + keyPassword = keystoreProperties.getProperty("keyPassword") + } + } + compileSdk = 36 + defaultConfig { + applicationId = "com.github.shingyx.boomswitch" + minSdk = 23 + targetSdk = 36 + versionCode = 13 + versionName = "1.9" + } + buildTypes { + getByName("debug") { + applicationIdSuffix = ".dev" + versionNameSuffix = "-dev" + } + getByName("release") { + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt")) + signingConfig = signingConfigs["release"] + } + } + buildFeatures { + buildConfig = true + viewBinding = true + } + kotlin { jvmToolchain(21) } +} + +ktfmt { googleStyle() } + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-stdlib:2.2.0") + implementation("androidx.appcompat:appcompat:1.7.1") + implementation("androidx.constraintlayout:constraintlayout:2.2.1") + implementation("com.google.android.gms:play-services-oss-licenses:17.2.2") + implementation("com.google.android.material:material:1.12.0") + implementation("com.jakewharton.timber:timber:5.0.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2") +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4c60973..0000000 --- a/build.gradle +++ /dev/null @@ -1,9 +0,0 @@ -buildscript { - ext.kotlin_version = '2.2.0' -} - -plugins { - id 'com.android.application' version '8.12.1' apply false - id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false - id 'com.ncorti.ktfmt.gradle' version '0.23.0' apply false -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..3710069 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,5 @@ +plugins { + id ("com.android.application") version "8.12.1" apply false + id ("org.jetbrains.kotlin.android") version "2.2.0" apply false + id ("com.ncorti.ktfmt.gradle") version "0.23.0" apply false +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 9bff6c1..0000000 --- a/settings.gradle +++ /dev/null @@ -1,24 +0,0 @@ -pluginManagement { - repositories { - google() - mavenCentral() - gradlePluginPortal() - } - resolutionStrategy { - eachPlugin { - if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") { - useModule("com.google.android.gms:oss-licenses-plugin:0.10.7") - } - } - } -} - -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} - -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..90a7dee --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,24 @@ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + resolutionStrategy { + eachPlugin { + if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") { + useModule("com.google.android.gms:oss-licenses-plugin:0.10.7") + } + } + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +include(":app") From 04ac5737d274ee2180864689970d9319b55c4363 Mon Sep 17 00:00:00 2001 From: Shingyx Date: Sun, 24 Aug 2025 13:13:18 +1000 Subject: [PATCH 3/3] version catalog --- app/build.gradle.kts | 22 +++++++++++----------- build.gradle.kts | 7 ++++--- gradle/libs.versions.toml | 26 ++++++++++++++++++++++++++ settings.gradle.kts | 2 +- 4 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 332d011..3e8fb17 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -3,10 +3,10 @@ import java.io.FileNotFoundException import java.util.Properties plugins { - id("com.android.application") - id("com.google.android.gms.oss-licenses-plugin") - id("com.ncorti.ktfmt.gradle") - id("kotlin-android") + alias(libs.plugins.android.application) + alias(libs.plugins.oss.licenses.plugin) + alias(libs.plugins.ktfmt) + alias(libs.plugins.kotlin.android) } val keystorePropertiesFile = rootProject.file("keystore.properties") @@ -57,11 +57,11 @@ android { ktfmt { googleStyle() } dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib:2.2.0") - implementation("androidx.appcompat:appcompat:1.7.1") - implementation("androidx.constraintlayout:constraintlayout:2.2.1") - implementation("com.google.android.gms:play-services-oss-licenses:17.2.2") - implementation("com.google.android.material:material:1.12.0") - implementation("com.jakewharton.timber:timber:5.0.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2") + implementation(libs.androidx.appcompat) + implementation(libs.androidx.constraintlayout) + implementation(libs.kotlin.stdlib) + implementation(libs.kotlinx.coroutines.android) + implementation(libs.material) + implementation(libs.oss.licenses) + implementation(libs.timber) } diff --git a/build.gradle.kts b/build.gradle.kts index 3710069..a5c01f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,6 @@ plugins { - id ("com.android.application") version "8.12.1" apply false - id ("org.jetbrains.kotlin.android") version "2.2.0" apply false - id ("com.ncorti.ktfmt.gradle") version "0.23.0" apply false + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.ktfmt) apply false + alias(libs.plugins.oss.licenses.plugin) apply false } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..29bb9ba --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,26 @@ +[versions] +agp = "8.12.1" +appcompat = "1.7.1" +constraintlayout = "2.2.1" +kotlin = "2.2.10" +kotlinxCoroutines = "1.10.2" +ktfmt = "0.23.0" +material = "1.12.0" +ossLicenses = "17.2.2" +ossLicensesPlugin = "0.10.7" +timber = "5.0.1" + +[libraries] +androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } +kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinxCoroutines" } +material = { module = "com.google.android.material:material", version.ref = "material" } +oss-licenses = { module = "com.google.android.gms:play-services-oss-licenses", version.ref = "ossLicenses" } +timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" } +oss-licenses-plugin = { id = "com.google.android.gms.oss-licenses-plugin", version.ref = "ossLicensesPlugin" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 90a7dee..a0a86f5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,7 +7,7 @@ pluginManagement { resolutionStrategy { eachPlugin { if (requested.id.id == "com.google.android.gms.oss-licenses-plugin") { - useModule("com.google.android.gms:oss-licenses-plugin:0.10.7") + useModule("com.google.android.gms:oss-licenses-plugin:${requested.version}") } } }