From fe46db08ebc744af1f03008db78ea6433f7a6357 Mon Sep 17 00:00:00 2001 From: sim Date: Sat, 9 Nov 2024 10:47:35 +0000 Subject: [PATCH] Migrate to Kotlin DSL --- app/build.gradle | 72 ------------------------------------- app/build.gradle.kts | 75 +++++++++++++++++++++++++++++++++++++++ build.gradle | 46 ------------------------ build.gradle.kts | 24 +++++++++++++ gradle.properties | 2 +- gradle/libs.versions.toml | 36 +++++++++++++++++++ settings.gradle | 2 -- settings.gradle.kts | 32 +++++++++++++++++ 8 files changed, 168 insertions(+), 121 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 0d93569..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,72 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' -} - -kotlin { - jvmToolchain(17) -} - -android { - compileSdk 34 - - defaultConfig { - applicationId "org.unifiedpush.distributor.nextpush" - minSdk 24 - targetSdk 34 - versionCode 29 - versionName "1.9.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildTypes { - release { - resValue "string", "app_name", "NextPush" - minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - debug { - resValue "string", "app_name", "NextPush-dbg" - applicationIdSuffix ".debug" - debuggable true - } - } - - namespace 'org.unifiedpush.distributor.nextpush' -} - -if (project.hasProperty('sign')) { - android { - signingConfigs { - release { - storeFile file(System.getenv("RELEASE_STORE_FILE")) - storePassword System.getenv("RELEASE_STORE_PASSWORD") - keyAlias System.getenv("RELEASE_KEY_ALIAS") - keyPassword System.getenv("RELEASE_KEY_PASSWORD") - } - } - } - android.buildTypes.release.signingConfig android.signingConfigs.release -} - -ext { - retrofitVersion = "2.9.0" -} - -dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version") - implementation("androidx.appcompat:appcompat:1.7.0") - implementation('com.google.android.material:material:1.12.0') - implementation("androidx.constraintlayout:constraintlayout:2.2.0") - implementation("androidx.coordinatorlayout:coordinatorlayout:1.2.0") - implementation('com.squareup.okhttp3:okhttp-sse:5.0.0.SSEPATCH1-SNAPSHOT') - implementation("com.github.nextcloud:Android-SingleSignOn:0.8.1") - implementation("com.squareup.retrofit2:retrofit:$retrofitVersion") - implementation("com.squareup.retrofit2:converter-gson:$retrofitVersion") - implementation("com.squareup.retrofit2:adapter-rxjava3:$retrofitVersion") - implementation('io.reactivex.rxjava3:rxjava:3.1.8') - implementation("io.reactivex.rxjava3:rxandroid:3.0.2") - implementation('androidx.work:work-runtime-ktx:2.9.0') -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..2c4b4dd --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,75 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) +} + +kotlin { + jvmToolchain(17) +} + +android { + compileSdk = 34 + + defaultConfig { + applicationId = "org.unifiedpush.distributor.nextpush" + minSdk = 24 + targetSdk = 34 + versionCode = 29 + versionName = "1.9.0" + } + + buildTypes { + getByName("release") { + resValue("string", "app_name", "NextPush") + isMinifyEnabled = true + isShrinkResources = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + getByName("debug") { + resValue("string", "app_name", "NextPush-dbg") + applicationIdSuffix = ".debug" + isDebuggable = true + } + } + + namespace = "org.unifiedpush.distributor.nextpush" +} + +if (project.hasProperty("sign")) { + android { + signingConfigs { + create("release") { + storeFile = file(System.getenv("RELEASE_STORE_FILE")) + storePassword = System.getenv("RELEASE_STORE_PASSWORD") + keyAlias = System.getenv("RELEASE_KEY_ALIAS") + keyPassword = System.getenv("RELEASE_KEY_PASSWORD") + } + } + + buildTypes { + getByName("release") { + signingConfig = signingConfigs.getByName("release") + } + } + } +} + + +dependencies { + implementation(libs.androidx.constraintlayout) + implementation(libs.androidx.coordinatorlayout) + implementation(libs.androidx.work.runtime.ktx) + implementation(libs.appcompat) + implementation(libs.kotlin.stdlib) + implementation(libs.material) + implementation(libs.nexctloud.sso) + implementation(libs.okhttp.sse) + implementation(libs.retrofit.adapter.rxjava3) + implementation(libs.retrofit.converter.gson) + implementation(libs.retrofit.retrofit) + implementation(libs.rxjava3.rxandroid) + implementation(libs.rxjava3.rxjava) +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index dc8a7f1..0000000 --- a/build.gradle +++ /dev/null @@ -1,46 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - ext.kotlin_version = '1.9.22' - repositories { - google() - mavenCentral() - maven { - url "https://plugins.gradle.org/m2/" - content { - includeModule 'org.jlleitschuh.gradle', 'ktlint-gradle' - } - } - } - dependencies { - classpath 'com.android.tools.build:gradle:8.7.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jlleitschuh.gradle:ktlint-gradle:11.5.1" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - mavenCentral() - maven { - url "https://www.jitpack.io" - content { - includeModule 'com.github.nextcloud', 'Android-SingleSignOn' - } - } - maven { - url "https://codeberg.org/NextPush/maven/raw/branch/main/okhttp-sse/releases/" - content { - includeModule "com.squareup.okhttp3", "okhttp-sse" - } - } - mavenLocal() - } - apply plugin: "org.jlleitschuh.gradle.ktlint" -} - -task clean(type: Delete) { - delete rootProject.buildDir -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..26d3cae --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,24 @@ + +buildscript { + dependencies { + classpath(libs.kotlin.gradle.plugin) + classpath(libs.ktlint.gradle) + } +} + +/* + * By listing all the plugins used throughout all subprojects in the root project build script, it + * ensures that the build script classpath remains the same for all projects. This avoids potential + * problems with mismatching versions of transitive plugin dependencies. A subproject that applies + * an unlisted plugin will have that plugin and its dependencies _appended_ to the classpath, not + * replacing pre-existing dependencies. + */ +plugins { + alias(libs.plugins.android.application) apply false + alias(libs.plugins.kotlin.android) apply false + alias(libs.plugins.ktlint) +} + +tasks.register("clean") { + delete(rootProject.layout.buildDirectory) +} diff --git a/gradle.properties b/gradle.properties index 6dadfc4..445f002 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,6 +20,6 @@ android.useAndroidX=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official org.gradle.unsafe.configuration-cache=true -android.defaults.buildfeatures.buildconfig=true +android.defaults.buildfeatures.buildconfig=false android.nonTransitiveRClass=true android.nonFinalResIds=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..bd27246 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,36 @@ +[versions] +android-gradle-plugin = "8.7.1" +androidx-constraintlayout = "2.2.0" +androidx-coordinatorlayout = "1.2.0" +androidx-work = "2.9.1" +appcompat = "1.7.0" +kotlin = "1.9.22" +ktlint = "11.5.1" +material = "1.12.0" +nextcloud-sso = "1.3.2" +okhttp-sse = "5.0.0.SSEPATCH1-SNAPSHOT" +retrofit = "2.9.0" +rxjava3-rxandroid = "3.0.2" +rxjava3-rxjava = "3.1.9" + +[libraries] +androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" } +androidx-coordinatorlayout = { module = "androidx.coordinatorlayout:coordinatorlayout", version.ref = "androidx-coordinatorlayout" } +androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "androidx-work" } +appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } +kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" } +ktlint-gradle = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint"} +material = { module = "com.google.android.material:material", version.ref = "material" } +nexctloud-sso = { module = "com.github.nextcloud:Android-SingleSignOn", version.ref = "nextcloud-sso" } +okhttp-sse = { module = "com.squareup.okhttp3:okhttp-sse", version.ref = "okhttp-sse" } +retrofit-adapter-rxjava3 = { module = "com.squareup.retrofit2:adapter-rxjava3", version.ref = "retrofit" } +retrofit-converter-gson = { module = "com.squareup.retrofit2:converter-gson", version.ref = "retrofit" } +retrofit-retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +rxjava3-rxandroid = { module = "io.reactivex.rxjava3:rxandroid", version.ref = "rxjava3-rxandroid" } +rxjava3-rxjava = { module = "io.reactivex.rxjava3:rxjava", version.ref = "rxjava3-rxjava" } + +[plugins] +android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" } +kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index ecc417e..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -include ':app' -rootProject.name = "NextPush" \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..b822a54 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,32 @@ +import java.net.URI + +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven { + url = URI("https://www.jitpack.io") + content { + includeModule("com.github.nextcloud", "Android-SingleSignOn") + } + } + maven { + url = URI("https://codeberg.org/NextPush/maven/raw/branch/main/okhttp-sse/releases/") + content { + includeModule("com.squareup.okhttp3", "okhttp-sse") + } + } + } +} + +include(":app") +rootProject.name = "NextPush"