Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle scripts migration, dependencies updating. #298

Open
wants to merge 1 commit into
base: starter_code
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions app/build.gradle

This file was deleted.

89 changes: 89 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.googleKsp)
alias(libs.plugins.kotlinKapt)
alias(libs.plugins.androidxSafeargs)
}

android {
compileSdk = libs.versions.compileSdkVersion.get().toInt()

namespace = "com.example.android.architecture.blueprints.todoapp"

defaultConfig {
applicationId = "com.example.android.architecture.blueprints.reactive"
minSdk = libs.versions.minSdkVersion.get().toInt()
targetSdk = libs.versions.targetSdkVersion.get().toInt()
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildFeatures {
buildConfig = true
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles.addAll(
listOf(
getDefaultProguardFile("proguard-android-optimize.txt"),
file("proguard-rules.pro")
)
)
}
}

dataBinding {
enable = true
enableForTests = true
}

val javaVersion = JavaVersion.toVersion(libs.versions.javaVersion.get())

compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}

kotlinOptions {
jvmTarget = javaVersion.toString()
}
}

dependencies {

// App dependencies
implementation(libs.androidx.appcompat)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.material)
implementation(libs.androidx.recyclerview)
implementation(libs.androidx.annotations)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.timber)

// Architecture Components
implementation(libs.androidx.room.runtime)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.commonJava8)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)

// Dependencies for local unit tests
testImplementation(libs.junit)

// AndroidX Test - Instrumented testing
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

// Kotlin
implementation(libs.kotlin.stdlib)
implementation(libs.androidx.fragment.ktx)
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ open class Event<out T>(private val content: T) {
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
*/
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let {
override fun onChanged(event: Event<T>) {
event.getContentIfNotHandled()?.let {
onEventUnhandledContent(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class TasksViewModel(application: Application) : AndroidViewModel(application) {
private var resultMessageShown: Boolean = false

// This LiveData depends on another so we can use a transformation.
val empty: LiveData<Boolean> = Transformations.map(_items) {
val empty: LiveData<Boolean> = _items.map {
it.isEmpty()
}

Expand Down
51 changes: 0 additions & 51 deletions build.gradle

This file was deleted.

7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
alias(libs.plugins.androidApplication).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.googleKsp).apply(false)
alias(libs.plugins.kotlinKapt).apply(false)
alias(libs.plugins.androidxSafeargs).apply(false)
}
61 changes: 61 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[versions]

minSdkVersion = "21"
targetSdkVersion = "34"
compileSdkVersion = "34"

agpVersion = "8.2.2"
javaVersion = "1.8"
kotlinVersion = "1.9.23"
kspVersion = "1.9.23-1.0.20"
navigationVersion = "2.7.7"

androidXVersion = "1.0.0"
androidXTestCoreVersion = "1.3.0"
androidXTestExtKotlinRunnerVersion = "1.1.5"
androidXTestRulesVersion = "1.2.0"
androidXAnnotations = "1.7.1"
appCompatVersion = "1.6.1"
archLifecycleVersion = "2.7.0"
coroutinesVersion = "1.8.0"
cardVersion = "1.0.0"
espressoVersion = "3.5.1"
fragmentKtxVersion = "1.6.2"
junitVersion = "4.13.2"
materialVersion = "1.11.0"
recyclerViewVersion = "1.3.2"
roomVersion = "2.6.1"
rulesVersion = "1.0.1"
swipeRefreshLayoutVersion = "1.1.0"
timberVersion = "5.0.1"

[libraries]

androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompatVersion" }
androidx-annotations = { module = "androidx.annotation:annotation", version.ref = "androidXAnnotations" }
androidx-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espressoVersion" }
androidx-fragment-ktx = { module = "androidx.fragment:fragment-ktx", version.ref = "fragmentKtxVersion" }
androidx-junit = { module = "androidx.test.ext:junit", version.ref = "androidXTestExtKotlinRunnerVersion" }
androidx-lifecycle-commonJava8 = { module = "androidx.lifecycle:lifecycle-common-java8", version.ref = "archLifecycleVersion" }
androidx-lifecycle-livedata-ktx = { module = "androidx.lifecycle:lifecycle-livedata-ktx", version.ref = "archLifecycleVersion" }
androidx-lifecycle-viewmodel-ktx = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref = "archLifecycleVersion" }
androidx-navigation-fragment-ktx = { module = "androidx.navigation:navigation-fragment-ktx", version.ref = "navigationVersion" }
androidx-navigation-ui-ktx = { module = "androidx.navigation:navigation-ui-ktx", version.ref = "navigationVersion" }
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerViewVersion" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "roomVersion" }
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "roomVersion" }
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "roomVersion" }
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "swipeRefreshLayoutVersion" }
junit = { module = "junit:junit", version.ref = "junitVersion" }
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlinVersion" }
kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutinesVersion" }
material = { module = "com.google.android.material:material", version.ref = "materialVersion" }
timber = { module = "com.jakewharton.timber:timber", version.ref = "timberVersion" }

[plugins]

androidApplication = { id = "com.android.application", version.ref = "agpVersion" }
androidxSafeargs = { id = "androidx.navigation.safeargs.kotlin", version.ref = "navigationVersion" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }
kotlinKapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlinVersion" }
googleKsp = { id = "com.google.devtools.ksp", version.ref = "kspVersion" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jun 14 12:47:31 UTC 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
1 change: 0 additions & 1 deletion settings.gradle

This file was deleted.

16 changes: 16 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pluginManagement {
repositories {
google()
mavenCentral()
}
}

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

include(":app")