Skip to content

Conversation

marcossalto
Copy link
Contributor

@marcossalto marcossalto commented Mar 2, 2022

Description

In Android Studio, Gradle build scripts in our project structure use Groovy build language. We mainly define plugins, project settings and dependencies in our Gradle scripts.
Writing code in these Gradle scripts doesn't seem excited since we're not very familiar with Groovy language.
A Kotlin build script can contain any Kotlin language element.

Since most of us use Kotlin for development, it's easier and more flexible to have build scripts in Kotlin instead of Groovy.
Kotlin DSL is based on the Kotlin core language. So the syntax is the same as the parent language, which gives us the benefit of using Kotlin for development. Kotlin DSL is fully compatible with Android Studio.

For that reason we find interesting migrating Groovy build scripts (.gradle) to Kotlin build scripts (.gradle.kts) for better reusability and easy maintenance


Tasks

  • Updated Koin library to 3.1.3
  • Updated KtLint library to 0.44.0
  • Optimized buildSrc module for Gradle Dependencies Management
  • Updated App name
  • Optimized app for Android 12
  • Added pre-push GitHook

Notes

We can list some benefits of choosing Kotlin DSL over Groovy

  • Good readability
  • Easily adaptable Kotlin syntax from the parent language
  • Code navigation and automatic suggestions
  • Bugs at compile time

Gradle Dependencies Management

We use buildSrc + Kotlin DSL
For more information, please visit Gradle Kotlin DSL Primer

Updated Koin library to 3.1.3
Updated KtLint library to 0.44.0
Optimized buildSrc module for Gradle Dependencies Management
Updated App name
Optimized app for Android 12
Added pre-push GitHook
@marcossalto marcossalto changed the title Migrated Groovy (*.gradle) to Kotlin (*.gradle.kts) Migrate Gradle Groovy (*.gradle) to Gradle Kotlin (*.gradle.kts) Mar 2, 2022
when (it) {
ProfileState.SIGN_OUT_FAILURE -> showError(viewModel.error)
ProfileState.SIGN_OUT_SUCCESS -> goToFirstScreen()
viewModel.state.observe(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use it like above?

viewModel.state.observe(this) {
}

viewModel.state.observe(
this
) {
it?.run {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename it ?

Copy link
Collaborator

@amaury901130 amaury901130 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcossalto looks like you added two new modules, could you explain a little bit more in the PR description these changes, before approval, also I'd documented these changes in the Readme file including a link to Gradle Kotlin docs to learn more about it.

@marcossalto marcossalto merged commit 300c07c into master-koin Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants