From 0660d39672e3a91c4b81ad2fa133beb2cc959a6a Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 1 Sep 2023 15:44:34 +0530 Subject: [PATCH] Migrate build scripts to use version catalogs and kts --- app/build.gradle | 93 ------------------- app/build.gradle.kts | 109 +++++++++++++++++++++++ build.gradle | 30 ------- build.gradle.kts | 11 +++ gradle.properties | 1 + gradle/libs.versions.toml | 69 ++++++++++++++ gradle/wrapper/gradle-wrapper.properties | 4 +- settings.gradle | 1 - settings.gradle.kts | 16 ++++ 9 files changed, 208 insertions(+), 126 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 8f2f9175..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,93 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-kapt' - -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.musicplayer" - minSdkVersion 23 - targetSdkVersion 33 - versionCode 114 - versionName "5.17.1" - setProperty("archivesBaseName", "music-player") - 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 - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - coreLibraryDesugaringEnabled = true - } -} - -dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:f76d729b9d' - implementation 'org.greenrobot:eventbus:3.3.1' - implementation 'androidx.media:media:1.6.0' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.lifecycle:lifecycle-process:2.5.1' - implementation 'androidx.media3:media3-session:1.1.1' - implementation 'androidx.media3:media3-exoplayer:1.1.1' - implementation 'com.google.android.material:material:1.6.1' - implementation 'com.airbnb.android:lottie:3.6.1' - implementation 'com.github.bjoernpetersen:m3u-parser:1.3.0' - implementation 'me.grantland:autofittextview:0.2.1' - coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:1.1.5') - - // higher versions of jaudiotagger not compatible with <= API 25 devices - // https://bitbucket.org/ijabz/jaudiotagger/issues/149/some-nio-classes-are-unavailable-while - implementation "net.jthink:jaudiotagger:2.2.5" - 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 00000000..00dc29bf --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,109 @@ +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() + versionName = project.libs.versions.app.version.versionName.get() + versionCode = project.libs.versions.app.version.versionCode.get().toInt() + setProperty("archivesBaseName", "music-player") + vectorDrawables.useSupportLibrary = true + } + + signingConfigs { + if (keystorePropertiesFile.exists()) { + register("release") { + keyAlias = keystoreProperties["keyAlias"] as String + keyPassword = keystoreProperties["keyPassword"] as String + storeFile = file(keystoreProperties["storeFile"] as String) + storePassword = keystoreProperties["storePassword"] as String + } + } + } + + 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 + isCoreLibraryDesugaringEnabled = true + } + + 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.eventbus) + implementation(libs.androidx.media) + implementation(libs.androidx.swiperefreshlayout) + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.lifecycle.process) + implementation(libs.androidx.media3.session) + implementation(libs.androidx.media3.exoplayer) + implementation(libs.lottie) + implementation(libs.m3u.parser) + implementation(libs.autofittextview) + implementation(libs.jaudiotagger) + coreLibraryDesugaring(libs.desugar.jdk.libs) + + implementation(libs.bundles.room) + ksp(libs.androidx.room.compiler) +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 5dc760b4..00000000 --- a/build.gradle +++ /dev/null @@ -1,30 +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() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' - 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() - 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 00000000..28727709 --- /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.properties b/gradle.properties index 95e3e292..cfecf3f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,4 @@ android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx8192m +android.nonTransitiveRClass=false diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..fe4515e3 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,69 @@ +[versions] +#jetbrains +autofittextview = "0.2.1" +desugar_jdk_libs = "2.0.3" +# higher versions of jaudiotagger not compatible with <= API 25 devices +# https://bitbucket.org/ijabz/jaudiotagger/issues/149/some-nio-classes-are-unavailable-while +jaudiotagger = "2.2.5" +kotlin = "1.9.0" +#KSP +ksp = "1.9.0-1.0.12" +#AndroidX +androidx-constraintlayout = "2.1.4" +androidx-swiperefreshlayout = "1.1.0" +androidx-lifecycleprocess = "2.6.1" +#Eventbus +eventbus = "3.3.1" +#Room +lottie = "6.1.0" +m3uParser = "1.3.0" +media = "1.6.0" +media3 = "1.1.1" +room = "2.5.2" +#Simple Mobile Tools +simple-commons = "adb7dea7ee" +#Gradle +gradlePlugins-agp = "8.1.0" +#build +app-build-compileSDKVersion = "34" +app-build-targetSDK = "34" +app-build-minimumSDK = "23" +app-build-javaVersion = "VERSION_17" +app-build-kotlinJVMTarget = "17" +#Helpers +shortcut-badger = "1.1.22" +#versioning +app-version-appId = "com.simplemobiletools.musicplayer" +app-version-versionCode = "114" +app-version-versionName = "5.17.1" +[libraries] +#AndroidX +androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" } +androidx-lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "androidx-lifecycleprocess" } +androidx-media = { module = "androidx.media:media", version.ref = "media" } +androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3" } +androidx-media3-session = { module = "androidx.media3:media3-session", version.ref = "media3" } +androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-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" } +#EventBus +eventbus = { module = "org.greenrobot:eventbus", version.ref = "eventbus" } +#Helpers +desugar_jdk_libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar_jdk_libs" } +jaudiotagger = { module = "net.jthink:jaudiotagger", version.ref = "jaudiotagger" } +lottie = { module = "com.airbnb.android:lottie", version.ref = "lottie" } +autofittextview = { module = "me.grantland:autofittextview", version.ref = "autofittextview" } +m3u-parser = { module = "com.github.bjoernpetersen:m3u-parser", version.ref = "m3uParser" } +[bundles] +room = [ + "androidx-room-ktx", + "androidx-room-runtime", +] +[plugins] +android = { id = "com.android.application", version.ref = "gradlePlugins-agp" } +kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 30eef37e..1847f1cd 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Nov 02 17:54:10 CET 2020 +#Thu Aug 31 16:28:32 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 e7b4def4..00000000 --- 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 00000000..45478cbe --- /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")