Migrate Gradle Groovy (*.gradle) to Gradle Kotlin (*.gradle.kts)#61
Merged
marcossalto merged 5 commits intomaster-koinfrom Mar 15, 2022
Merged
Conversation
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
| when (it) { | ||
| ProfileState.SIGN_OUT_FAILURE -> showError(viewModel.error) | ||
| ProfileState.SIGN_OUT_SUCCESS -> goToFirstScreen() | ||
| viewModel.state.observe( |
Contributor
There was a problem hiding this comment.
can we use it like above?
viewModel.state.observe(this) {
}
| viewModel.state.observe( | ||
| this | ||
| ) { | ||
| it?.run { |
Contributor
There was a problem hiding this comment.
can we rename it ?
ximenaperez
approved these changes
Mar 9, 2022
Collaborator
amaury901130
left a comment
There was a problem hiding this comment.
@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.
agustinkoll-rootstrap
approved these changes
Mar 14, 2022
amaury901130
approved these changes
Mar 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Notes
We can list some benefits of choosing Kotlin DSL over Groovy
Gradle Dependencies Management
We use buildSrc + Kotlin DSL
For more information, please visit Gradle Kotlin DSL Primer