Migrate to Kotlin DSL

This commit is contained in:
sim 2024-11-09 10:47:35 +00:00
parent 3c89647889
commit fe46db08eb
8 changed files with 168 additions and 121 deletions

View File

@ -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')
}

75
app/build.gradle.kts Normal file
View File

@ -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)
}

View File

@ -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
}

24
build.gradle.kts Normal file
View File

@ -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<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

View File

@ -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

36
gradle/libs.versions.toml Normal file
View File

@ -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" }

View File

@ -1,2 +0,0 @@
include ':app'
rootProject.name = "NextPush"

32
settings.gradle.kts Normal file
View File

@ -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"