Skip to content

Commit

Permalink
Updated gradle plugins to use version catalog and migrated to ksp
Browse files Browse the repository at this point in the history
  • Loading branch information
HeyPouya committed Jul 20, 2024
1 parent 5f0b0f4 commit dc9634e
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 59 deletions.
21 changes: 9 additions & 12 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-kapt")
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
alias(libs.plugins.ksp)
alias(libs.plugins.hiltGradle)
id("kotlin-parcelize")
id("dagger.hilt.android.plugin")
}

android {
Expand Down Expand Up @@ -38,9 +38,9 @@ android {
}

dependencies {
implementation(project(":features:widget"))
implementation(project(":core"))
implementation(project(":features:calendar-details"))
implementation(projects.features.widget)
implementation(projects.core)
implementation(projects.features.calendarDetails)
// Kotlin
implementation(libs.androidx.core)

Expand All @@ -59,10 +59,7 @@ dependencies {

// Hilt Library
implementation(libs.hilt.android)
kapt(libs.hilt.android.compiler)
kapt(libs.hilt.compiler)
ksp(libs.hilt.android.compiler)
ksp(libs.hilt.compiler)

}
kapt {
correctErrorTypes = true
}
3 changes: 0 additions & 3 deletions app/src/main/java/ir/apptune/calendar/base/BaseApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ package ir.apptune.calendar.base
import android.app.Application
import dagger.hilt.android.HiltAndroidApp

/**
* Application class
*/
@HiltAndroidApp
class BaseApplication : Application()
31 changes: 9 additions & 22 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath(libs.agp)
classpath(libs.kotlin.gradle.plugin)
classpath(libs.hilt.gradle.plugin)
}
}

allprojects {
repositories {
mavenCentral()
google()
}
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
plugins {
alias(libs.plugins.androidApplication) apply false
alias(libs.plugins.androidLibrary) apply false
alias(libs.plugins.jetbrainsKotlinAndroid) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.compose.compiler) apply false
alias(libs.plugins.hiltGradle) apply false
alias(libs.plugins.ksp) apply false
}
6 changes: 4 additions & 2 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id("com.android.library")
id("kotlin-android")
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsKotlinAndroid)
id("kotlin-parcelize")
}

Expand All @@ -25,6 +25,8 @@ dependencies {
implementation(libs.androidx.core)
implementation(libs.appcompat)
implementation(libs.material)

// Test
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.espresso)
Expand Down
16 changes: 8 additions & 8 deletions features/calendar-details/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsKotlinAndroid)
alias(libs.plugins.ksp)
alias(libs.plugins.hiltGradle)
}
android {
compileSdk = libs.versions.compileSdkVersion.get().toInt()
Expand All @@ -24,7 +24,8 @@ android {
}

dependencies {
implementation(project(":core"))
implementation(projects.core)

implementation(libs.androidx.core)
implementation(libs.appcompat)
implementation(libs.material)
Expand All @@ -34,11 +35,10 @@ dependencies {

// Hilt Library
implementation(libs.hilt.android)
kapt(libs.hilt.android.compiler)
kapt(libs.hilt.compiler)
ksp(libs.hilt.android.compiler)
ksp(libs.hilt.compiler)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.espresso)

}
16 changes: 8 additions & 8 deletions features/widget/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
alias(libs.plugins.androidLibrary)
alias(libs.plugins.jetbrainsKotlinAndroid)
alias(libs.plugins.ksp)
alias(libs.plugins.hiltGradle)
}

android {
Expand All @@ -22,18 +22,18 @@ android {
}

dependencies {
implementation(project(":core"))
implementation(projects.core)

implementation(libs.androidx.core)
implementation(libs.appcompat)
implementation(libs.material)

// Hilt Library
implementation(libs.hilt.android)
kapt(libs.hilt.android.compiler)
kapt(libs.hilt.compiler)
ksp(libs.hilt.android.compiler)
ksp(libs.hilt.compiler)

testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.espresso)

}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Dfile.encoding\=UTF-8 -XX\:+UseParallelGC -Xmx10G
kotlin.code.style=official
android.enableAppCompileTimeRClass=true
android.nonTransitiveRClass=true
android.nonTransitiveRClass=false
android.nonFinalResIds=true
android.useAndroidX=true
org.gradle.parallel=true
12 changes: 10 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ core= "1.13.1"
junit = "4.13.2"
androidJunit = "1.2.1"
espresso = "3.6.1"
ksp = "2.0.0-1.0.21"

[libraries]
agp = { module = "com.android.tools.build:gradle", version.ref = "agp" }
kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref="appcompat" }
constraintLayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref="constraintLayout" }
recyclerView = { group = "androidx.recyclerview", name = "recyclerview", version.ref="recyclerView" }
Expand All @@ -45,3 +44,12 @@ androidx-core = { group = "androidx.core", name = "core-ktx", version.ref="core"
junit = { group = "junit", name = "junit", version.ref="junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref="androidJunit" }
espresso = { group = "androidx.test.espresso", name = "espresso-core", version.ref="espresso" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
jetbrainsKotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
hiltGradle = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
23 changes: 22 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
include(":app", ":features:widget", ":core", ":features:calendar-details")
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include(":app")
include(":features:widget")
include(":core")
include(":features:calendar-details")

0 comments on commit dc9634e

Please sign in to comment.