From 75c393461f2c8c26f0a1ad195069f32de48b0cdd Mon Sep 17 00:00:00 2001 From: Luke Wass Date: Mon, 12 May 2025 12:32:14 -0500 Subject: [PATCH] migrate build files to kotlin --- app/build.gradle | 116 ---------------------------- app/build.gradle.kts | 158 ++++++++++++++++++++++++++++++++++++++ app/proguard-rules.pro | 2 +- build.gradle | 35 --------- build.gradle.kts | 13 ++++ gradle.properties | 2 +- gradle/libs.versions.toml | 71 +++++++++++++++++ settings.gradle | 2 - settings.gradle.kts | 24 ++++++ 9 files changed, 268 insertions(+), 155 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 7e92f3b..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,116 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' -apply plugin: 'kotlinx-serialization' - -android { - dataBinding { - enabled = true - } - - packaging { - resources.excludes.addAll( - [ - "META-INF/LICENSE.md", - "META-INF/NOTICE.md", - "META-INF/LICENSE-notice.md" - ] - ) - } - - defaultConfig { - applicationId "de.jrpie.android.launcher" - minSdkVersion 21 - targetSdkVersion 35 - compileSdk 35 - versionCode 45 - versionName "0.2.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = '17' - } - - buildFeatures { - viewBinding true - } - - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - debug { - applicationIdSuffix = ".debug" - versionNameSuffix = "-debug" - } - } - - flavorDimensions += "distribution" - - productFlavors { - create("default") { - dimension = "distribution" - getIsDefault().set(true) - buildConfigField "boolean", "USE_ACCESSIBILITY_SERVICE", "true" - } - create("accrescent") { - dimension = "distribution" - applicationIdSuffix = ".accrescent" - versionNameSuffix = "+accrescent" - buildConfigField "boolean", "USE_ACCESSIBILITY_SERVICE", "false" - } - } - - sourceSets { - accrescent { - manifest.srcFile 'src/accrescent/AndroidManifest.xml' - } - } - - namespace 'de.jrpie.android.launcher' - buildFeatures { - buildConfig true - } - - dependenciesInfo { - // Disables dependency metadata when building APKs. - includeInApk = false - // Disables dependency metadata when building Android App Bundles. - includeInBundle = false - } - lint { - abortOnError false - } - - -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.activity:activity-ktx:1.8.0' - implementation 'androidx.appcompat:appcompat:1.7.0' - implementation 'androidx.core:core-ktx:1.15.0' - implementation 'androidx.constraintlayout:constraintlayout:2.2.0' - implementation 'androidx.gridlayout:gridlayout:1.0.0' - implementation 'androidx.palette:palette-ktx:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.4.0' - implementation 'androidx.preference:preference-ktx:1.2.1' - implementation 'com.google.android.material:material:1.12.0' - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation "eu.jonahbauer:android-preference-annotations:1.1.2" - implementation 'androidx.activity:activity:1.10.1' - annotationProcessor "eu.jonahbauer:android-preference-annotations:1.1.2" - annotationProcessor "com.android.databinding:compiler:$android_plugin_version" - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.2.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' -} - diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..7190581 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,158 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) + alias(libs.plugins.kotlin.kapt) + alias(libs.plugins.kotlin.serialization) +} + +android { + namespace = "de.jrpie.android.launcher" + compileSdk = 35 + + defaultConfig { + applicationId = "de.jrpie.android.launcher" + minSdk = 21 + targetSdk = 35 + versionCode = 46 + versionName = "0.2.1" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + debug { + applicationIdSuffix = ".debug" + versionNameSuffix = "-debug" + } + } + + flavorDimensions += "distribution" + + productFlavors { + create("default") { + dimension = "distribution" + isDefault = true + buildConfigField("boolean", "USE_ACCESSIBILITY_SERVICE", "true") + } + create("accrescent") { + dimension = "distribution" + applicationIdSuffix = ".accrescent" + versionNameSuffix = "+accrescent" + buildConfigField("boolean", "USE_ACCESSIBILITY_SERVICE", "false") + } + } + + sourceSets { + this.getByName("accrescent") { + this.java.srcDir("src/accrescent") + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } + buildFeatures { + buildConfig = true + compose = true + dataBinding = true + viewBinding = true + } + + dependenciesInfo { + includeInApk = false + includeInBundle = false + } + + lint { + abortOnError = false + } +} + +dependencies { + // implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + + // implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation(libs.kotlin.stdlib.jdk7) + + // implementation 'androidx.activity:activity-ktx:1.8.0' + implementation(libs.androidx.activity.ktx) + + // implementation 'androidx.appcompat:appcompat:1.7.0' + implementation(libs.androidx.appcompat) + + // implementation 'androidx.core:core-ktx:1.15.0' + implementation(libs.androidx.core.ktx) + + // implementation 'androidx.constraintlayout:constraintlayout:2.2.0' + implementation(libs.androidx.constraintlayout) + + // implementation 'androidx.gridlayout:gridlayout:1.0.0' + implementation(libs.androidx.gridlayout) + + // implementation 'androidx.palette:palette-ktx:1.0.0' + implementation(libs.androidx.palette.ktx) + + // implementation 'androidx.recyclerview:recyclerview:1.4.0' + implementation(libs.androidx.recyclerview) + + // implementation 'androidx.preference:preference-ktx:1.2.1' + implementation(libs.androidx.preference.ktx) + + // implementation 'com.google.android.material:material:1.12.0' + implementation(libs.google.material) + + // implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation(libs.kotlinx.serialization.json) + + // implementation "eu.jonahbauer:android-preference-annotations:1.1.2" + implementation(libs.jonahbauer.android.preference.annotations) + + // implementation 'androidx.activity:activity:1.10.1' + implementation(libs.androidx.activity) + + // annotationProcessor "eu.jonahbauer:android-preference-annotations:1.1.2" + // If you are using KSP, use ksp(...) instead of kapt(...) or annotationProcessor(...) + // Otherwise, if you still need kapt: + // kapt(libs.jonahbauer.android.preference.annotations) + // Or if you need annotationProcessor for Java libraries: + kapt(libs.jonahbauer.android.preference.annotations) + + // testImplementation 'junit:junit:4.13.2' + testImplementation(libs.junit) + + // androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation(libs.androidx.test.ext.junit) + + // androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' + androidTestImplementation(libs.androidx.espresso.core) + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(libs.androidx.appcompat) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 9e3e326..c1fba79 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -2,7 +2,7 @@ -dontobfuscate -dontoptimize # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build.gradle b/build.gradle deleted file mode 100644 index e128ac7..0000000 --- a/build.gradle +++ /dev/null @@ -1,35 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext.kotlin_version = '2.0.0' - ext.android_plugin_version = '8.10.0' - repositories { - google() - mavenCentral() - - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.10.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "com.android.tools.build:gradle:$android_plugin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - - } -} - -tasks.register('clean', Delete) { - delete layout.buildDirectory -} - diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..842176e --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,13 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.kotlin.compose) apply false + alias(libs.plugins.kotlin.kapt) apply false + alias(libs.plugins.kotlin.serialization) apply false +} + +tasks.register("clean", Delete::class) { + delete(layout.buildDirectory) +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 4093087..80aef5f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ org.gradle.jvmargs=-Xmx1536m # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true +android.enableJetifier=false # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official android.nonTransitiveRClass=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..2f41128 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,71 @@ +[versions] +agp = "8.10.0" +kotlin = "2.1.0" +kapt = "1.8.10" +serialization = "1.8.10" +junit = "4.13.2" +junitVersion = "1.2.1" +espresso-core = "3.6.1" +lifecycleRuntimeKtx = "2.9.0" +activityCompose = "1.10.1" +composeBom = "2025.05.00" +appcompat = "1.7.0" +constraintlayout = "2.2.0" +gridlayout = "1.0.0" +recyclerview = "1.4.0" +material = "1.12.0" +android-preference-annotations = "1.1.2" +activity = "1.10.1" +kotlinx-serialization-json = "1.7.3" +activity-ktx = "1.8.0" +core-ktx = "1.15.0" +palette-ktx = "1.0.0" +preference-ktx = "1.2.1" + +[libraries] +# AndroidX dependencies +androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" } +androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } +androidx-activity-ktx = { group = "androidx.activity", name = "activity-ktx", version.ref = "activity-ktx" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } +androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } +androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" } +androidx-gridlayout = { group = "androidx.gridlayout", name = "gridlayout", version.ref = "gridlayout" } +androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } +androidx-material3 = { group = "androidx.compose.material3", name = "material3" } +androidx-palette-ktx = { group = "androidx.palette", name = "palette-ktx", version.ref = "palette-ktx" } +androidx-preference-ktx = { group = "androidx.preference", name = "preference-ktx", version.ref = "preference-ktx" } +androidx-recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" } +androidx-ui = { group = "androidx.compose.ui", name = "ui" } +androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } + +# Google Material +google-material = { group = "com.google.android.material", name = "material", version.ref = "material" } + +# Kotlin and Serialization +kotlin-stdlib-jdk7 = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk7", version.ref = "kotlin" } # Use kotlin version +kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" } + +# Annotation Processors +jonahbauer-android-preference-annotations = { group = "eu.jonahbauer", name = "android-preference-annotations", version.ref = "android-preference-annotations" } +# The databinding library is bundled with the Android Gradle plugin. You do not need to declare a dependency on the library, but you must enable it in your module's build.gradle file. +# see https://developer.android.com/jetpack/androidx/releases/databinding +# android-databinding-compiler = { group = "com.android.databinding", name = "compiler", version.ref = "agp" } # Use agp version + +# Testing dependencies +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } +androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } +androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "agp" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } +kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kapt" } +kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "serialization" } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index b9709f4..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name='Launcher' -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..5054e60 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,24 @@ +pluginManagement { + repositories { + google { + content { + includeGroupByRegex("com\\.android.*") + includeGroupByRegex("com\\.google.*") + includeGroupByRegex("androidx.*") + } + } + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + } +} + +rootProject.name = "Launcher" +include(":app") \ No newline at end of file