Skip to content

Join the cool kids club (aka migrate to Gradle Kotlin DSL) #1321

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

Merged
merged 12 commits into from
May 30, 2018
Merged

Join the cool kids club (aka migrate to Gradle Kotlin DSL) #1321

merged 12 commits into from
May 30, 2018

Conversation

SUPERCILEX
Copy link
Collaborator

Surprise, I found another way to use Kotlin in FUI! 🎉😁

# Conflicts:
#	auth/build.gradle
#	constants.gradle
#	library/quality/quality.gradle
Signed-off-by: Alex Saveau <[email protected]>
@SUPERCILEX SUPERCILEX requested a review from samtstern as a code owner May 28, 2018 21:10
Signed-off-by: Alex Saveau <[email protected]>
@SUPERCILEX SUPERCILEX changed the base branch from master to version-4.1.0-dev May 29, 2018 02:16
@samtstern
Copy link
Contributor

@SUPERCILEX this is pretty cool! And does it fix the lint/aapt2 issue as well? If so I think we should release this as 4.0.1 which will also give me a chance to make sure that the full release process works with the refactored gradle files.

@samtstern samtstern added this to the 4.0.1 milestone May 29, 2018
@samtstern samtstern changed the base branch from version-4.1.0-dev to version-4.0.1-dev May 29, 2018 18:21
Copy link
Contributor

@samtstern samtstern left a comment

Choose a reason for hiding this comment

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

Mostly small comments

@@ -0,0 +1,59 @@
android {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a big comment on this file saying something like "hey we R cool kidz so we use the Kotlin DSL. If you're writing an app that uses FirebaseUI check out README.md for better examples" or something like that (please not that verbatim)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha, I'm definitely going to quote you on that one! 😁 Side note: do you think we should rename :app to :sample?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've gone ahead with that change though it's in one commit we can easily kill if you disagree.

auth/README.md Outdated
@@ -135,7 +135,7 @@ Twitter app as reported by the [Twitter application manager](https://apps.twitte
In addition, you must enable the "Request email addresses from users" permission
in the "Permissions" tab of your Twitter app.

In order to resolve the Twitter SDK, add the following repository to your `build.gradle`:
In order to resolve the Twitter SDK, add the following repository to your `build.gradle(.kts)`:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use the longhand "build.gradle or build.gradle.kts" everywhere to minimize confusion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've decided to simply remove those references since our samples won't compile in gradle.kts anyway. 🤷‍♂️


lintOptions {
disable("UnusedQuantity")
disable("UnknownNullness") // Too much to deal with right now
Copy link
Contributor

Choose a reason for hiding this comment

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

Fine with the disabling but can you explain what's going on?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I realize the nullability changes account for a lot more thrashing than originally anticipated. I've rebased those out and will make another PR with a better explanation. (As a short explanation, Tor is continuing his eternal quest to keep us on our toes with new lint checks. 😆)

build.gradle.kts Outdated
val Project.reportsDir get() = "$buildDir/reports"

fun Project.configureAndroid() {
apply(plugin = "com.android.${if (name == "app" || name == "proguard-tests") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is over my personal fanciness limit :-)

How about:

if (name == "app" || name == "proguard-tests") {
  // apply app plugin
} else {
  // apply library plugin

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha, np. 😁😊

build.gradle.kts Outdated
}

fun Project.setupPublishing(isLibrary: Boolean) {
val publicationName = "${if (isLibrary) "monolith" else name}Library"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer not to have expressions in strings. How about:

val publicationName = if (isLibrary) "monolithLibrary" else "${name}Library"

const val twitter = "com.twitter.sdk.android:twitter-core:3.1.1@aar"
}

object Miscellaneous {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit nit: shorten to Misc?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

*Goes back to his own project to fix that too* 😆

"check"(this, block)
}

private inline operator fun String.invoke(project: Project, crossinline block: Task.() -> Unit) =
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I'm not super sold on this either, but I've seen similar DSL before: the idea is to override what happens when you call "someString"(). In this case, we're saying you can do this:

"someTask"(myProject) {
    // Do stuff with the task
}

I don't mind killing it if you're dumbfoundedly confused like how I felt the first time I saw that kind of DSL. 😁

@@ -20,7 +21,8 @@ public PageKey(@Nullable DocumentSnapshot startAfter, @Nullable DocumentSnapshot
mEndBefore = endBefore;
}

public Query getPageQuery(Query baseQuery, int size) {
@NonNull
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the PR title to reflect all the nullability stuff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will be moved into another PR

@@ -6,5 +6,5 @@ import com.android.tools.lint.client.api.IssueRegistry
* Registry for custom FirebaseUI lint checks.
*/
class LintIssueRegistry : IssueRegistry() {
override fun getIssues() = listOf(NonGlobalIdDetector.NON_GLOBAL_ID)
override val issues = listOf(NonGlobalIdDetector.NON_GLOBAL_ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

override val --> Kotlin is cool but also sometimes it's stupid. This is not an actionable comment, just being grumpy Java guy.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Awww, c'mon!? How can you not love overriding fields? It's so clean! ✨

api(project(":auth"))
api(project(":database"))
api(project(":firestore"))
api(project(":storage"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need common here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We didn't have it before and Gradle should take care of downloading those kinds of transitive dependencies.

Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
@SUPERCILEX
Copy link
Collaborator Author

@samtstern Yup, it fixes the lint issues and I've merged from 4.0.1. 👍

@samtstern
Copy link
Contributor

@SUPERCILEX LGTM but the one part I don't agree with is app --> sample. Especially since it makes this PR touch 100+ files. Let's just rename it back to app and then we'll merge it and see if we can get 4.0.1 going.

Signed-off-by: Alex Saveau <[email protected]>
Signed-off-by: Alex Saveau <[email protected]>
@SUPERCILEX
Copy link
Collaborator Author

SGTM, though do you think it should be done at some point? Personally, "app" has always felt vague.

@samtstern
Copy link
Contributor

@SUPERCILEX I see app as a convention since it's what Android Studio calls the application module by default.

@samtstern samtstern merged commit f7cbc1e into firebase:version-4.0.1-dev May 30, 2018
@SUPERCILEX SUPERCILEX deleted the gradle-kotlin-dsl branch May 30, 2018 15:57
@SUPERCILEX
Copy link
Collaborator Author

Oh yeah, that makes sense since people will be familiar with it. 👍

@SUPERCILEX
Copy link
Collaborator Author

@samtstern huh, I broke the snapshot builds. 😭 I'll look into it this afternoon. Is standard publishing working?

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.

2 participants