-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(gradle): Add basic Gradle Kotlin DSL support #4086
Conversation
f684ca7
to
68e53a2
Compare
Thanks @ikesyo ! Hoping that @corecanarias has some spare time to review this soon |
68e53a2
to
aeb4bc0
Compare
dfea6a4
to
af9f34f
Compare
Hi @corecanarias @rarkins, is there any chance to get this reviewed? |
1c52adf
to
6d2bf98
Compare
@ikesyo thank you for this PR! I think @corecanarias is busy lately, but I'll try to take a look. Could you fix the conflicted file? |
Yes of course! |
7d64f88
to
1f235b7
Compare
@rarkins I've resolved the conflicts. |
lib/config/definitions.js
Outdated
fileMatch: [ | ||
'\\.gradle(\\.kts)?$', | ||
'(^|/)gradle.properties$', | ||
'(^|/)buildSrc/.*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is buildSrc needed in the fileMatch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entry is needed to detect/collect/update dependencies/variables defined in source files within buildSrc
.
As @jcornaz said in #3054, it is becoming popular that defining dependencies/versions in a Kotlin (or Java) source files under buildSrc
.
The other point to keep in mind is that (although not specific to the Kotlin DSL) storing version numbers in Java or Kotlin files in the
buildSrc
directory is quite popular among Kotlin DSL users (because it gives us good auto-completion and type-safety in build scripts)
For example:
- https://handstandsam.com/2018/02/11/kotlin-buildsrc-for-better-gradle-dependency-management/
- https://proandroiddev.com/gradle-dependency-management-with-kotlin-94eed4df9a28
Even though I don't handle contents such as:
object Versions {
val support_lib = "27.0.2"
val retrofit = "2.3.0"
val rxjava = "2.1.9"
}
object Libs {
val support_annotations = "com.android.support:support-annotations:${Versions.support_lib}"
val support_appcompat_v7 = "com.android.support:appcompat-v7:${Versions.support_lib}"
val retrofit = "com.squareup.retrofit2:retrofit:${Versions.retrofit}"
val retrofit_rxjava_adapter = "com.squareup.retrofit2:adapter-rxjava2:${Versions.retrofit}"
val rxjava = "io.reactivex.rxjava2:rxjava:${Versions.rxjava}"
}
but this PR should work against more simple cases (no enclosing types $Versions.fooVariable
) such as:
object Libs {
private val supportLibVersion = "27.0.2"
private val retrofitVersion = "2.3.0"
private val rxjavaVersion = "2.1.9"
val support_annotations = "com.android.support:support-annotations:${supportLibVersion}"
val support_appcompat_v7 = "com.android.support:appcompat-v7:${supportLibVersion}"
val retrofit = "com.squareup.retrofit2:retrofit:${retrofitVersion}"
val retrofit_rxjava_adapter = "com.squareup.retrofit2:adapter-rxjava2:${retrofitVersion}"
val rxjava = "io.reactivex.rxjava2:rxjava:${rxjavaVersion}"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reconsidered this. As you said in #3054 (comment), not adding buildSrc
to the fileMatch
and instead letting users add exact wanted files by themselves will be good (at least for now) as a first step.
Users extend
fileMatch
for any we miss. These would probably not bebuild.gradle
files but more likegradle.settings
files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rarkins I've just omitted the entry.
a225fc3
to
0ee9710
Compare
0ee9710
to
55389ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry it took so long :/
Thanks @ikesyo for the feature and @corecanarias for the review! |
🎉 This PR is included in version 19.22.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This partially implements #3054.
*.gradle.kts
andfiles are now recognizedbuildSrc/**/*
implementation(group = "...", name = "...", version = "...")