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

[Adaptive] Migrate gradle module til Kotlin DSL #1579

Merged
merged 3 commits into from
Apr 27, 2023

Conversation

oas004
Copy link
Contributor

@oas004 oas004 commented Apr 16, 2023

This is the first PR in a series to migrate the gradle files to use Kotlin DSL instead of Groovy. Since having Kotlin DSL and Groovy in the same project works fine, I thought migrating module by module was okay.

The related issue is #1578.

I have split up the PR into two commits. The first one prepares the file to be migrated by using steps described in these docs. The second one is where I actually convert the file to .kts file and updates the rest of the file to be compatible with Kotlin DSL.

I have added a line to suppress unstable API usage, since a lot of the APIs here are marked incubating. What do you guys think about that?


lint {
textReport = true
textOutput = File("stdout")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not quite sure about this, should this be set to the build folder maybe? 🤔

@bentrengrove
Copy link
Collaborator

Thank you for these! Sorry I have been slow to review, I have been OOO this week. Just catching up but should be able to get to them soon.

@oas004
Copy link
Contributor Author

oas004 commented Apr 24, 2023

Thank you for these! Sorry I have been slow to review, I have been OOO this week. Just catching up but should be able to get to them soon.

No worries at all! Take your time! :)

Copy link

@borisf borisf left a comment

Choose a reason for hiding this comment

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

Thanks a lot @oas004

}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
Copy link

Choose a reason for hiding this comment

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

Let's make it JavaVersion.Version_11, let me know if there is something we stuck on Java 8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I think this went fine :) Upgraded it in 6bbdef1 :)


compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Copy link

Choose a reason for hiding this comment

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

Same, lets make Java 11

testImplementation(libs.robolectric)
}

apply(plugin = "com.vanniktech.maven.publish")
Copy link

Choose a reason for hiding this comment

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

@file:Suppress("UnstableApiUsage")

plugins {
id("com.android.library")
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried this, but since we are on agp version 7.4.1 I think we have this issue (gradle/gradle#17968) since we have to maintain the class path version as well. I can do a workaround like this
id(libs.plugins.android.library.get().pluginId) would that be okay?

Copy link

Choose a reason for hiding this comment

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

Yes please, as we continue to enjoy the catalogs, and we can change this code once the Gradle bug is fixed

Copy link

Choose a reason for hiding this comment

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

On the same thought we should move to AGP 8.0 which is stable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this in 6bbdef1 :) Moving to AGP 8.0, should that maybe be in a separate PR if these are squashed in case it breaks something? Wdyt? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can take a look into upgrading to AGP 8.0 parallel to this :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an attempt on this here: #1590

Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this now solve the need for using pluginId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to rebase this locally and upgrading does not fix it. I think the fix is to migrate all the plugins at classpath to use the alias and then update this to use alias as well. The reason I think this is that the sync error is that it already has this plugin on the classpath with an unknown version, so the compatibility cannot be checked.

I can fix it if I add the pluginManagment block with repositories block to settings.gradle and then remove the classpath decleration and move the plugins to the plugins block using the alias there as well in the project gradle file. Should I do that here? Or wait until I migrate the project gradle and settings gradle file to Kotlin DSL? Or I can do it in a seperate PR if you want to seperate these two things.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's wait until you migrate those other files and go with the current solution for now. I will merge this one in!

@@ -0,0 +1,134 @@
/*
* Copyright 2022 The Android Open Source Project
Copy link

@borisf borisf Apr 24, 2023

Choose a reason for hiding this comment

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

Shouldn't it be 2023

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 6bbdef1 :) Thanks!

Copy link

@borisf borisf left a comment

Choose a reason for hiding this comment

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

@bentrengrove bentrengrove merged commit 295d382 into google:main Apr 27, 2023
9 checks passed
@bentrengrove
Copy link
Collaborator

This just needs rebasing I think. Can you please rebase and reopen a PR when ready?

@oas004
Copy link
Contributor Author

oas004 commented Apr 28, 2023

Ah yes, I'm not quite sure why this build before we bumped AGP 8.0.0, but I had to revert the Java target version in this module to 1.8 to get it to compile. I think this is because we are setting 1.8 in project gradle. Maybe it makes sense to migrate everything there to 11 in bulk? Sorry about this, I should have rebased it before and checked.
Reopened a PR here #1593

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.

None yet

3 participants