Migration from gradle groovy to kotlin kts (#525)

* versions improvements

* improvements

* remove navigatio  plugin

* migrated gradle files from grovvy to kts
This commit is contained in:
Yogesh Choudhary Paliyal
2023-05-10 14:43:22 +05:30
committed by GitHub
parent 3f0a2db28d
commit 9fef76a3f4
115 changed files with 378 additions and 423 deletions

View File

@@ -20,7 +20,6 @@ jobs:
name: 'Spotless, Tests and Build Production Debug Build'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setting up project
@@ -28,9 +27,6 @@ jobs:
- name: 🛠 Build Project with Spotless Check
run: ./gradlew spotlessCheck
- name: 🏗 Build With gradle
run: bash ./gradlew build
- name: 🧪 Run Tests
run: ./gradlew test

1
.java-version Normal file
View File

@@ -0,0 +1 @@
openjdk64-11.0.11

View File

@@ -1,172 +0,0 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
id("dagger.hilt.android.plugin")
id("com.spotify.ruler")
}
def appPackageId = 'com.yogeshpaliyal.keypass'
android {
compileSdk 33
defaultConfig {
applicationId appPackageId
minSdk 23
targetSdk 33
versionCode 1412
versionName "1.4.12"
testInstrumentationRunner "com.yogeshpaliyal.keypass.CustomTestRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
// debug {
// minifyEnabled true
// shrinkResources true
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// }
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
freeCompilerArgs += [
'-Xopt-in=androidx.compose.material3.ExperimentalMaterial3Api'
]
}
buildFeatures {
compose true
viewBinding = true
dataBinding = true
}
flavorDimensions "default"
productFlavors {
production {
}
staging {
applicationIdSuffix ".staging"
}
}
sourceSets {
main {
res {
srcDirs 'src\\main\\res', 'src\\staging\\res'
}
}
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.4"
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
namespace appPackageId
/*sourceSets {
main {
res {
srcDirs 'src\\main\\res', 'src\\staging\\res', '..\\common\\src\\staging\\res'
}
}
}*/
}
ruler {
abi.set("arm64-v8a")
locale.set("en")
screenDensity.set(480)
sdkVersion.set(27)
}
dependencies {
api project(":common")
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
// Test rules and transitive dependencies:
androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.4.3")
// Needed for createAndroidComposeRule, but not createComposeRule:
debugImplementation("androidx.compose.ui:ui-test-manifest:1.4.3")
implementation "androidx.compose.ui:ui:1.4.3"
implementation "androidx.compose.ui:ui-tooling-preview:1.4.2"
implementation "androidx.compose.ui:ui-viewbinding:1.4.3"
implementation 'androidx.activity:activity-compose:1.7.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
implementation "androidx.compose.material:material-icons-extended:1.4.2"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.4.3"
debugImplementation "androidx.compose.ui:ui-tooling:1.4.3"
implementation("androidx.compose.runtime:runtime-livedata:1.4.3")
implementation "androidx.navigation:navigation-compose:2.5.3"
implementation 'androidx.compose.material3:material3:1.1.0-rc01'
implementation "com.google.accompanist:accompanist-themeadapter-material3:0.30.1"
// XML Libraries
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference-ktx:1.2.0'
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
kapt "androidx.room:room-compiler:$room_version"
// dependency injection
implementation("com.google.dagger:hilt-android:$hilt_version")
kapt("com.google.dagger:hilt-android-compiler:$hilt_version")
implementation("androidx.hilt:hilt-work:1.0.0")
// When using Kotlin.
kapt("androidx.hilt:hilt-compiler:1.0.0")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
// zxing library
// implementation "com.googl.ezxing:android-core:3.4.1"
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
// For instrumented tests.
androidTestImplementation("com.google.dagger:hilt-android-testing:2.46")
// ...with Kotlin.
kaptAndroidTest("com.google.dagger:hilt-android-compiler:$hilt_version")
// For Robolectric tests.
testImplementation("com.google.dagger:hilt-android-testing:2.46")
// ...with Kotlin.
kaptTest("com.google.dagger:hilt-android-compiler:$hilt_version")
implementation "org.reduxkotlin:redux-kotlin-compose-jvm:0.6.0"
implementation "me.saket.cascade:cascade-compose:2.0.0-rc02"
}

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

@@ -0,0 +1,168 @@
plugins {
id("com.android.application")
id("kotlin-android")
kotlin("kapt")
id("dagger.hilt.android.plugin")
id("com.spotify.ruler")
id("com.google.dagger.hilt.android")
}
val appPackageId = "com.yogeshpaliyal.keypass"
android {
compileSdk = 33
defaultConfig {
applicationId = appPackageId
minSdk = 23
targetSdk = 33
versionCode = 1412
versionName = "1.4.12"
testInstrumentationRunner = "com.yogeshpaliyal.keypass.CustomTestRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
// debug {
// minifyEnabled true
// shrinkResources true
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
// }
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs = listOf(
"-Xopt-in=androidx.compose.material3.ExperimentalMaterial3Api"
)
}
buildFeatures {
compose = true
viewBinding = true
dataBinding = true
}
flavorDimensions("default")
productFlavors {
create("production") {
}
create("staging") {
applicationIdSuffix = ".staging"
}
}
sourceSets {
getByName("main") {
res.srcDirs("src/main/res", "src/staging/res")
}
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.4"
}
packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
namespace = appPackageId
/*sourceSets {
main {
res {
srcDirs 'src\\main\\res', 'src\\staging\\res', '..\\common\\src\\staging\\res'
}
}
}*/
}
ruler {
abi.set("arm64-v8a")
locale.set("en")
screenDensity.set(480)
sdkVersion.set(27)
}
dependencies {
api(project(":common"))
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.test:core-ktx:1.5.0")
androidTestImplementation("androidx.test.ext:junit-ktx:1.1.5")
// Test rules and transitive dependencies:
androidTestImplementation("androidx.compose.ui:ui-test-junit4:${Versions.compose}")
// Needed for createAndroidComposeRule, but not createComposeRule:
debugImplementation("androidx.compose.ui:ui-test-manifest:${Versions.compose}")
androidTestImplementation("androidx.compose.ui:ui-test-junit4:${Versions.compose}")
debugImplementation("androidx.compose.ui:ui-tooling:${Versions.compose}")
implementation(Deps.Compose.ui)
implementation(Deps.Compose.uiTooling)
implementation(Deps.Compose.uiToolingPreview)
implementation(Deps.Compose.uiViewBinding)
implementation(Deps.Compose.materialIconsExtended)
implementation(Deps.Compose.activity)
implementation(Deps.Compose.runtimeLiveData)
implementation(Deps.Lifecycle.viewModelCompose)
implementation(Deps.Lifecycle.viewModelKtx)
implementation(Deps.Lifecycle.runtimeCompose)
implementation("androidx.navigation:navigation-compose:2.5.3")
implementation("androidx.compose.material3:material3:1.1.0-rc01")
implementation("com.google.accompanist:accompanist-themeadapter-material3:0.30.1")
implementation("androidx.appcompat:appcompat:1.6.1")
// XML Libraries
implementation("org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
kapt("androidx.room:room-compiler:${Versions.room}")
// dependency injection
implementation("com.google.dagger:hilt-android:${Versions.hilt}")
kapt("com.google.dagger:hilt-android-compiler:${Versions.hilt}")
implementation("androidx.hilt:hilt-work:1.0.0")
// When using Kotlin.
kapt("androidx.hilt:hilt-compiler:1.0.0")
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
// zxing library
// implementation "com.googl.ezxing:android-core:3.4.1"
implementation("com.journeyapps:zxing-android-embedded:4.3.0")
// For instrumented tests.
androidTestImplementation("com.google.dagger:hilt-android-testing:2.46")
// ...with Kotlin.
kaptAndroidTest("com.google.dagger:hilt-android-compiler:${Versions.hilt}")
// For Robolectric tests.
testImplementation("com.google.dagger:hilt-android-testing:2.46")
// ...with Kotlin.
kaptTest("com.google.dagger:hilt-android-compiler:${Versions.hilt}")
implementation("org.reduxkotlin:redux-kotlin-compose-jvm:0.6.0")
implementation("me.saket.cascade:cascade-compose:2.0.0-rc02")
}

View File

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

View File

@@ -2,9 +2,9 @@ package com.yogeshpaliyal.keypass.ui.nav
import android.os.Bundle
import android.view.WindowManager
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
@@ -75,7 +75,7 @@ import org.reduxkotlin.compose.selectState
import java.util.Locale
@AndroidEntryPoint
class DashboardComposeActivity : AppCompatActivity() {
class DashboardComposeActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -108,7 +108,7 @@ fun Dashboard() {
LaunchedEffect(key1 = systemBackPress, block = {
if (systemBackPress) {
(context as? AppCompatActivity)?.onBackPressed()
(context as? ComponentActivity)?.onBackPressed()
}
})

View File

@@ -1,54 +0,0 @@
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<PreferenceCategory>
<Preference app:summary="@string/backup_desc" />
<Preference
app:key="@string/settings_start_backup"
app:title="@string/turn_on_backup" />
<Preference
app:key="@string/settings_create_backup"
app:title="@string/create_backup"
tools:summary="Last backup : 7m" />
<Preference
app:key="@string/settings_backup_folder"
app:title="@string/backup_folder"
tools:summary="@string/backup" />
<Preference
app:key="@string/settings_auto_backup"
app:title="@string/auto_backup"
tools:summary="@string/disabled" />
<PreferenceCategory
app:key="@string/settings_cat_auto_backup"
app:title="@string/auto_backup"
app:allowDividerBelow="true">
<Preference app:summary="Your accounts will be backed up whenever account is added or modified" />
<Preference
app:key="@string/settings_override_auto_backup"
app:title="@string/override_auto_backup_file"
tools:summary="@string/disabled" />
</PreferenceCategory>
<Preference
app:key="@string/settings_verify_key_phrase"
app:summary="@string/verify_keyphrase_message"
app:title="@string/verify_keyphrase" />
<Preference
app:isPreferenceVisible="false"
app:key="@string/settings_stop_backup"
app:title="@string/turn_off_backup" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:key="security_category"
app:title="@string/security">
<Preference
app:key="@string/settings_backup"
app:title="@string/credentials_backups"
app:summary="@string/credentials_backups_desc" />
<Preference
app:key="@string/settings_restore_backup"
app:title="@string/restore_credentials"
app:summary="@string/restore_credentials_desc" />
</PreferenceCategory>
<PreferenceCategory
app:key="help_category"
app:title="@string/help">
<Preference
app:key="@string/settings_feedback"
app:icon="@drawable/ic_baseline_feedback_24"
app:title="@string/send_feedback"
app:summary="@string/send_feedback_desc" />
<Preference
app:key="@string/settings_share_app"
app:icon="@drawable/ic_baseline_share_24"
app:title="@string/share"
app:summary="@string/share_desc" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -1,67 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext{
kotlin_version = "1.8.10"
lifecycle_version = "2.6.1"
room_version = "2.5.1"
navigation_version = '2.5.3'
ext.hilt_version = '2.45'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath("com.spotify.ruler:ruler-gradle-plugin:1.4.0")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'com.diffplug.spotless' version '6.18.0'
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
/*task clean(type: Delete) {
delete rootProject.buildDir
}*/
subprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
apply plugin: 'com.diffplug.spotless'
spotless {
kotlin {
target '**/*.kt'
targetExclude("$buildDir/**/*.kt")
targetExclude('bin/**/*.kt')
java.util.HashMap<String, String> map = new HashMap<>();
ktlint("0.46.0").userData(map)
// licenseHeaderFile rootProject.file('spotless/copyright.kt')
}
}
}

50
build.gradle.kts Normal file
View File

@@ -0,0 +1,50 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
}
dependencies {
classpath ("com.android.tools.build:gradle:7.4.2")
classpath ("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}")
classpath ("com.google.gms:google-services:4.3.15")
classpath ("com.google.dagger:hilt-android-gradle-plugin:${Versions.hilt}")
classpath ("com.spotify.ruler:ruler-gradle-plugin:1.4.0")
classpath ("com.gradle:gradle-enterprise-gradle-plugin:3.13.2")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
}
}
plugins {
id ("com.diffplug.spotless") version("6.18.0")
id("org.jetbrains.kotlin.kapt") version(Versions.kotlin)
id("com.google.dagger.hilt.android") version "2.44" apply false
}
/*task clean(type: Delete) {
delete rootProject.buildDir
}*/
subprojects {
repositories {
google()
maven("https://jitpack.io")
}
apply(plugin = "com.diffplug.spotless")
spotless {
kotlin {
target("**/*.kt")
targetExclude("$buildDir/**/*.kt")
targetExclude("bin/**/*.kt")
val map = HashMap<String, String>();
ktlint("0.46.0").userData(map)
// licenseHeaderFile rootProject.file('spotless/copyright.kt')
}
}
}

View File

@@ -0,0 +1,8 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "1.6.10"
}
repositories {
mavenCentral()
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose$activity$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose$materialIconsExtended$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose$runtimeLiveData$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose$ui$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose$uiTooling$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose$uiToolingPreview$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose$uiViewBinding$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Compose.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$ComposeAndroidTest.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Lifecycle$runtimeCompose$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Lifecycle$viewModelCompose$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Lifecycle$viewModelKtx$2.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps$Lifecycle.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Deps.class:/Users/yogesh.choudhary3/YogeshPaliyalStudioProjects/KeyPass/buildSrc/build/classes/kotlin/main/Versions.class

Some files were not shown because too many files have changed in this diff Show More