From c6b7df23ed215e1315651a44c9b253f0c789fe37 Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Sat, 17 Jun 2023 04:20:24 +0300 Subject: [PATCH] refactor: move from groovy to kotlinscript for gradle files and upgrade gradle --- app/build.gradle | 87 ---------------- app/build.gradle.kts | 127 +++++++++++++++++++++++ app/proguard-rules.pro | 2 +- build.gradle => build.gradle.kts | 19 ++-- gradle.properties | 3 + gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 2 - settings.gradle.kts | 2 + 8 files changed, 144 insertions(+), 100 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts rename build.gradle => build.gradle.kts (55%) 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 dc3d3ac..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,87 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-parcelize' - id 'kotlin-kapt' -} - -def keystoreProperties = new Properties() -def keystorePropertiesFile = rootProject.file('keystore.properties') -if (keystorePropertiesFile.exists()) { - keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) -} - -android { - namespace 'com.illusionware.npsbrowser' - compileSdkVersion 33 - - defaultConfig { - applicationId "com.illusionware.npsbrowser" - minSdkVersion 23 - targetSdkVersion 33 - versionCode 1 - versionName "0.1.0" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - - buildFeatures { - dataBinding = true - viewBinding = true - } - - signingConfigs { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] - } - } - - buildTypes { - release { - signingConfig signingConfigs.release - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - buildToolsVersion '33.0.1' - -} - -repositories { - google() - mavenCentral() -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'androidx.appcompat:appcompat:1.6.0' - implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' - implementation 'com.github.doyaaaaaken:kotlin-csv-jvm:1.8.0' - implementation 'com.github.wrdlbrnft:sorted-list-adapter:0.3.0.27' - implementation "androidx.cardview:cardview:1.0.0" - implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3' - implementation 'androidx.navigation:navigation-ui-ktx:2.5.3' - implementation 'androidx.preference:preference-ktx:1.2.0' - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.2.1' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation 'com.google.android.material:material:1.8.0' - implementation 'com.github.bumptech.glide:glide:4.14.2' - annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2' - implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..8e03af1 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,127 @@ +import java.util.Properties +import java.io.FileInputStream + +plugins { + id("com.android.application") + kotlin("android") + id("kotlin-parcelize") + id("kotlin-kapt") +} + +val keystoreProperties = Properties() +val keystorePropertiesFile = rootProject.file("keystore.properties") +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(FileInputStream(keystorePropertiesFile)) +} + +android { + namespace = "com.illusionware.npsbrowser" + compileSdk = 33 + + defaultConfig { + applicationId = "com.illusionware.npsbrowser" + minSdk = 23 + targetSdk = 33 + versionCode = 1 + versionName = "0.1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildFeatures { + viewBinding = true + compose = true + + aidl = false + renderScript = false + shaders = false + } + + signingConfigs { + create("release") { + keyAlias = keystoreProperties["keyAlias"] as String? + keyPassword = keystoreProperties["keyPassword"] as String? + storeFile = keystoreProperties["storeFile"]?.let { file(it) } + storePassword = keystoreProperties["storePassword"] as String? + } + } + + buildTypes { + named("release") { + signingConfig = signingConfigs.getByName("release") + isMinifyEnabled = false + proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro") + } + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + composeOptions { + kotlinCompilerExtensionVersion = "1.4.4" + } + buildToolsVersion = "33.0.1" + kotlinOptions { + jvmTarget = "17" + } + packagingOptions { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } + +} + +repositories { + google() + mavenCentral() +} + +dependencies { + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1") + implementation("androidx.activity:activity-compose:1.5.1") + implementation(platform("androidx.compose:compose-bom:2022.10.00")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + androidTestImplementation(platform("androidx.compose:compose-bom:2022.10.00")) + androidTestImplementation("androidx.compose.ui:ui-test-junit4") + // Jetpack Compose + val composeBom = platform("androidx.compose:compose-bom:2023.04.01") + implementation(composeBom) + androidTestImplementation(composeBom) + + // Material 3 + implementation("androidx.compose.material3:material3") + // Android Studio Preview support + implementation("androidx.compose.ui:ui-tooling-preview") + debugImplementation("androidx.compose.ui:ui-tooling") + + implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.core:core-ktx:1.10.1") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("androidx.coordinatorlayout:coordinatorlayout:1.2.0") + implementation("com.github.doyaaaaaken:kotlin-csv-jvm:1.8.0") + implementation("com.github.wrdlbrnft:sorted-list-adapter:0.3.0.27") + implementation("androidx.cardview:cardview:1.0.0") + implementation("androidx.navigation:navigation-fragment-ktx:2.6.0") + implementation("androidx.navigation:navigation-ui-ktx:2.6.0") + implementation("androidx.preference:preference-ktx:1.2.0") + implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1") + implementation("androidx.legacy:legacy-support-v4:1.0.0") + implementation("androidx.recyclerview:recyclerview:1.3.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + implementation("com.google.android.material:material:1.9.0") + implementation("com.github.bumptech.glide:glide:4.14.2") + annotationProcessor("com.github.bumptech.glide:compiler:4.14.2") + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") + debugImplementation("androidx.compose.ui:ui-test-manifest") + implementation("androidx.core:core-splashscreen:1.0.1") +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f1b4245..2f9dc5a 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # 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.kts similarity index 55% rename from build.gradle rename to build.gradle.kts index 791db56..16b3c2f 100644 --- a/build.gradle +++ b/build.gradle.kts @@ -1,17 +1,16 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext { - kotlin_version = '1.8.10' - } + val kotlin_version = "1.8.10" + repositories { google() + mavenCentral() jcenter() - } dependencies { - classpath 'com.android.tools.build:gradle:7.4.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath("com.android.tools.build:gradle:8.0.2") + 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 @@ -21,11 +20,13 @@ buildscript { allprojects { repositories { google() + mavenCentral() jcenter() - } } -task clean(type: Delete) { - delete rootProject.buildDir +tasks { + register("clean", Delete::class) { + delete(rootProject.buildDir) + } } diff --git a/gradle.properties b/gradle.properties index 23339e0..9e73ebc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,3 +19,6 @@ android.useAndroidX=true android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a965789..78ffdb0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 7e567b9..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name='NPS Browser' -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..c591ac9 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name="NPS Browser" +include("app")