From 5f41894872592d289888581a15ad46a649bad5c6 Mon Sep 17 00:00:00 2001 From: Naveen Date: Wed, 30 Aug 2023 19:10:13 +0530 Subject: [PATCH] Migrate build scripts to use version catalogs and kts --- app/build.gradle | 84 ------------------- app/build.gradle.kts | 100 +++++++++++++++++++++++ app/src/main/AndroidManifest.xml | 1 - build.gradle | 32 -------- build.gradle.kts | 11 +++ gradle/libs.versions.toml | 48 +++++++++++ gradle/wrapper/gradle-wrapper.properties | 4 +- settings.gradle | 1 - settings.gradle.kts | 16 ++++ 9 files changed, 177 insertions(+), 120 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 create mode 100644 gradle/libs.versions.toml 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 096c2c52d..000000000 --- a/app/build.gradle +++ /dev/null @@ -1,84 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-android-extensions' - id 'kotlin-kapt' - id 'de.timfreiheit.resourceplaceholders' -} - -def keystorePropertiesFile = rootProject.file("keystore.properties") -def keystoreProperties = new Properties() -if (keystorePropertiesFile.exists()) { - keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) -} - -android { - compileSdkVersion 33 - - defaultConfig { - applicationId "com.simplemobiletools.calendar.pro" - minSdkVersion 23 - targetSdkVersion 33 - versionCode 238 - versionName "6.22.2" - multiDexEnabled true - setProperty("archivesBaseName", "calendar") - vectorDrawables.useSupportLibrary = true - } - - signingConfigs { - if (keystorePropertiesFile.exists()) { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] - } - } - } - - buildTypes { - debug { - applicationIdSuffix ".debug" - } - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - if (keystorePropertiesFile.exists()) { - signingConfig signingConfigs.release - } - } - } - - flavorDimensions "variants" - productFlavors { - core {} - fdroid {} - prepaid {} - } - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lintOptions { - checkReleaseBuilds false - abortOnError false - } - - resourcePlaceholders { - files = ['xml/shortcuts.xml'] - } -} - -dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:8814cd2d4b' - implementation 'androidx.multidex:multidex:2.0.1' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' - implementation "androidx.print:print:1.0.0" - - kapt 'androidx.room:room-compiler:2.5.2' - implementation 'androidx.room:room-runtime:2.5.2' - annotationProcessor 'androidx.room:room-compiler:2.5.2' -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 000000000..4cc9a4016 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,100 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.jetbrains.kotlin.konan.properties.Properties +import java.io.FileInputStream + +plugins { + alias(libs.plugins.android) + alias(libs.plugins.kotlinAndroid) + alias(libs.plugins.ksp) +} + +val keystorePropertiesFile: File = rootProject.file("keystore.properties") +val keystoreProperties = Properties() +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(FileInputStream(keystorePropertiesFile)) +} + +android { + compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt() + + defaultConfig { + applicationId = libs.versions.app.version.appId.get() + minSdk = project.libs.versions.app.build.minimumSDK.get().toInt() + targetSdk = project.libs.versions.app.build.targetSDK.get().toInt() + versionCode = project.libs.versions.app.version.versionCode.get().toInt() + versionName = project.libs.versions.app.version.versionName.get() + multiDexEnabled = true + setProperty("archivesBaseName", "calendar") + vectorDrawables.useSupportLibrary = true + } + + signingConfigs { + if (keystorePropertiesFile.exists()) { + register("release") { + keyAlias = keystoreProperties.getProperty("keyAlias") + keyPassword = keystoreProperties.getProperty("keyPassword") + storeFile = file(keystoreProperties.getProperty("storeFile")) + storePassword = keystoreProperties.getProperty("storePassword") + } + } + } + + buildFeatures { + viewBinding = true + buildConfig = true + } + + buildTypes { + debug { + applicationIdSuffix = ".debug" + } + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + if (keystorePropertiesFile.exists()) { + signingConfig = signingConfigs.getByName("release") + } + } + } + + flavorDimensions.add("variants") + productFlavors { + register("core") + register("fdroid") + register("prepaid") + } + + sourceSets { + getByName("main").java.srcDirs("src/main/kotlin") + } + + compileOptions { + val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString()) + sourceCompatibility = currentJavaVersionFromLibs + targetCompatibility = currentJavaVersionFromLibs + } + + tasks.withType { + kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get() + } + + namespace = libs.versions.app.version.appId.get() + + lint { + checkReleaseBuilds = false + abortOnError = false + } +} + +dependencies { + implementation(libs.simple.mobile.tools.commons) + implementation(libs.androidx.multidex) + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.swiperefreshlayout) + implementation(libs.androidx.print) + implementation(libs.bundles.room) + ksp(libs.androidx.room.compiler) +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 143c4d4d7..89a65a2ef 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 77cc0cb7b..000000000 --- a/build.gradle +++ /dev/null @@ -1,32 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext.kotlin_version = '1.7.10' - - repositories { - google() - mavenCentral() - maven { url "https://plugins.gradle.org/m2" } - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "de.timfreiheit.resourceplaceholders:placeholders:0.4" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - maven { url "https://jitpack.io" } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..287277090 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + alias(libs.plugins.android).apply(false) + alias(libs.plugins.kotlinAndroid).apply(false) + alias(libs.plugins.ksp).apply(false) +} + +tasks.register("clean") { + delete { + rootProject.buildDir + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..90dc780d5 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,48 @@ +[versions] +#jetbrains +kotlin = "1.9.0" +#KSP +ksp = "1.9.0-1.0.12" +#Androidx +multidex = "2.0.1" +print = "1.0.0" +constraintlayout = "2.1.4" +swiperefreshlayout = "1.1.0" +#Room +room = "2.5.2" +#Simple tools +simple-commons = "7c1e5b5777" +#Gradle +gradlePlugins-agp = "8.1.1" +#build +app-build-compileSDKVersion = "34" +app-build-targetSDK = "33" +app-build-minimumSDK = "23" +app-build-javaVersion = "VERSION_17" +app-build-kotlinJVMTarget = "17" +#versioning +app-version-appId = "com.simplemobiletools.calendar.pro" +app-version-versionCode = "238" +app-version-versionName = "6.22.2" +[libraries] +#Android X +androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } +androidx-multidex = { module = "androidx.multidex:multidex", version.ref = "multidex" } +androidx-print = { module = "androidx.print:print", version.ref = "print" } +androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swiperefreshlayout" } +#Room +androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" } +androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" } +androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" } +#Simple Mobile Tools +simple-mobile-tools-commons = { module = "com.github.SimpleMobileTools:Simple-Commons", version.ref = "simple-commons" } +[bundles] +room = [ + "androidx-room-ktx", + "androidx-room-runtime", +] +[plugins] +android = { id = "com.android.application", version.ref = "gradlePlugins-agp" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } +kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f7a68f777..f2a39e218 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Nov 02 19:09:05 CET 2020 +#Wed Aug 30 15:51:27 IST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e7b4def49..000000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 000000000..45478cbec --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,16 @@ +pluginManagement { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven { setUrl("https://jitpack.io") } + } +} +include(":app")