From 5e500e2ec7a6e0dacb6c4e02d8ad99dcd666c3d2 Mon Sep 17 00:00:00 2001 From: Chirag Thummar Date: Sat, 12 Aug 2023 18:38:32 +0530 Subject: [PATCH 1/2] Gradle Migrated To Version Catalog --- .idea/gradle.xml | 1 + app/build.gradle | 86 ----------------- app/build.gradle.kts | 115 +++++++++++++++++++++++ app/proguard-rules.pro | 2 +- build.gradle | 10 -- build.gradle.kts | 21 +++++ gradle.properties | 3 +- gradle/libs.versions.toml | 56 +++++++++++ gradle/wrapper/gradle-wrapper.properties | 6 +- settings.gradle => settings.gradle.kts | 3 +- 10 files changed, 201 insertions(+), 102 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 rename settings.gradle => settings.gradle.kts (94%) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index ae388c2a..757f88ef 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -14,6 +14,7 @@ + diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index c8865d31..00000000 --- a/app/build.gradle +++ /dev/null @@ -1,86 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' - id 'kotlin-kapt' -} - -android { - namespace 'com.bnyro.clock' - compileSdk 33 - - defaultConfig { - applicationId "com.bnyro.clock" - minSdk 21 - targetSdk 33 - versionCode 8 - versionName "5.1" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary true - } - - javaCompileOptions { - annotationProcessorOptions { - arguments += ["room.schemaLocation": "$projectDir/schemas".toString()] - } - } - } - - buildTypes { - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - debug { - debuggable true - applicationIdSuffix '.debug' - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = '1.8' - } - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion '1.4.2' - } - packagingOptions { - resources { - excludes += '/META-INF/{AL2.0,LGPL2.1}' - } - } -} - -dependencies { - - // Core and UI - implementation 'androidx.core:core-ktx:1.10.1' - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1' - implementation 'androidx.activity:activity-compose:1.7.2' - implementation "androidx.compose.ui:ui:$compose_version" - implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" - implementation 'androidx.navigation:navigation-compose:2.6.0' - - // Material and icons - implementation 'androidx.compose.material3:material3:1.2.0-alpha02' - implementation 'com.google.android.material:material:1.9.0' - implementation 'androidx.compose.material:material-icons-extended:1.4.3' - - // Room database - implementation 'androidx.room:room-ktx:2.5.1' - kapt "androidx.room:room-compiler:2.5.1" - - // Testing - 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.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 00000000..3b28015e --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,115 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("kotlin-kapt") +} + +android { + namespace = "com.bnyro.clock" + compileSdk = 33 + + defaultConfig { + applicationId = "com.bnyro.clock" + minSdk = 21 + targetSdk = 33 + versionCode = 8 + versionName = "5.1" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + + javaCompileOptions { + annotationProcessorOptions { + compilerArgumentProviders( + RoomSchemaArgProvider(File(projectDir, "schemas")) + ) + } + } + } + + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + debug { + isDebuggable = true + applicationIdSuffix = ".debug" + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.4.3" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + + //Core And UI + implementation(libs.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + implementation(libs.lifecycle.runtime.ktx) + implementation(libs.activity.compose) + implementation(libs.lifecycle.runtime.ktx) + implementation(libs.navigation.compose) + + //Compose BOM + implementation(platform(libs.compose.bom)) + implementation(libs.ui) + implementation(libs.ui.graphics) + implementation(libs.ui.tooling.preview) + + //Material Theme + implementation(libs.material3) + implementation(libs.material) + implementation(libs.material.icons.extended) + + + implementation(libs.ui.viewbinding) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.test.ext.junit) + androidTestImplementation(libs.espresso.core) + androidTestImplementation(platform(libs.compose.bom)) + androidTestImplementation(libs.ui.test.junit4) + debugImplementation(libs.ui.tooling) + debugImplementation(libs.ui.test.manifest) + + + //Room DB + kapt(libs.room.compiler) + implementation(libs.room.runtime) + implementation(libs.room.ktx) +} + +class RoomSchemaArgProvider( +@get:InputDirectory +@get:PathSensitive(PathSensitivity.RELATIVE) +val schemaDir: File +) : CommandLineArgumentProvider { + + override fun asArguments(): Iterable { + // Note: If you're using KSP, change the line below to return + // listOf("room.schemaLocation=${schemaDir.path}"). + return listOf("-Aroom.schemaLocation=${schemaDir.path}") + } +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb434..ff59496d 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 deleted file mode 100644 index e0942469..00000000 --- a/build.gradle +++ /dev/null @@ -1,10 +0,0 @@ -buildscript { - ext { - compose_version = '1.4.3' - } -}// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id 'com.android.application' version '7.4.2' apply false - id 'com.android.library' version '7.4.2' apply false - id 'org.jetbrains.kotlin.android' version '1.8.10' apply false -} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..bff46201 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,21 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + + dependencies { + // Add this line + classpath(libs.kotlin.gradle.plugin) + } + repositories { + mavenCentral() + } +} + +plugins { + alias(libs.plugins.androidApplication) apply false + alias(libs.plugins.kotlinAndroid) apply false + alias(libs.plugins.library) apply false + +} +true // Needed to make the Suppress annotation work for the plugins block + + diff --git a/gradle.properties b/gradle.properties index 3c5031eb..11a9b244 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,5 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true +android.defaults.buildfeatures.buildconfig=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..3f3755ad --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,56 @@ +[versions] +agp = "7.4.2" +kotlin = "1.8.10" +core-ktx = "1.9.0" +junit = "4.13.2" +androidx-test-ext-junit = "1.1.5" +espresso-core = "3.5.1" +kotlin-gradle-plugin = "1.8.10" +lifecycle-runtime-ktx = "2.6.1" +activity-compose = "1.7.2" +compose-bom = "2023.06.00" +library = "8.0.1" +material = "1.9.0" +navigation-compose = "2.5.3" +material-icons-extended = "1.4.3" +room = "2.5.1" +androidx-appcompat = "1.6.1" + +[libraries] +core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" } +junit = { group = "junit", name = "junit", version.ref = "junit" } +androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" } +espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" } +kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin-gradle-plugin" } +lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" } +activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" } +compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" } +ui-viewbinding = { group = "androidx.compose.ui", name = "ui-viewbinding" } +ui = { group = "androidx.compose.ui", name = "ui" } +ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } +ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } +ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } +ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } +ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } +material3 = { group = "androidx.compose.material3", name = "material3" } +appcompat = { group = "androidx.appcompat", name = "appcompat" } +material = { group = "com.google.android.material", name = "material" , version.ref = "material"} +constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout" } +androidx-appcompat = { group = "androidx.appcompat", name = "appcompat",version.ref="androidx-appcompat" } +multidex = { group = "androidx.multidex", name = "multidex" } +material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended", version.ref="material-icons-extended" } + +#Compose +navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref="navigation-compose" } + +#Room Database +room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room"} +room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room"} + +#Kotlin Extensions and Coroutines support for Room +room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room"} + +[plugins] +androidApplication = { id = "com.android.application", version.ref = "agp" } +kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } +library = { id = "com.android.library", version.ref = "library" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a619784e..182165c3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Apr 06 09:25:18 CEST 2023 +#Sat Aug 12 18:27:58 IST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle.kts similarity index 94% rename from settings.gradle rename to settings.gradle.kts index 40b392b3..199d592e 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -12,5 +12,6 @@ dependencyResolutionManagement { mavenCentral() } } + rootProject.name = "Clock You" -include ':app' +include(":app") From 37f09fcec0936db9563032dc8012792c79186f56 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Sat, 12 Aug 2023 18:53:49 +0200 Subject: [PATCH 2/2] ci: bump java version to 17 --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e1ca30c..ed1931bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,10 +21,10 @@ jobs: steps: - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: "temurin" cache: "gradle" - name: Compile