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

Multiplatform: Port :zoomable module to Compose Multiplatform #10

Closed
wants to merge 10 commits into from
Closed

Multiplatform: Port :zoomable module to Compose Multiplatform #10

wants to merge 10 commits into from

Conversation

DSteve595
Copy link
Collaborator

@DSteve595 DSteve595 commented May 15, 2023

#9

This adds a convention plugin for modules using Kotlin Multiplatform + Jetbrains Compose, and migrates the :zoomable module to use it.

Things to note:

  • The Compose compiler plugin is set to the AndroidX one rather than the Jetbrains one. I'm not sure if that matters.
  • AndroidX Compose libraries are still in libs.toml, but can (should) be removed once all modules are moved over.
  • Migrated :zoomable's build.gradle to KTS, since the Jetbrains Compose Gradle plugin adds some useful dependency declarations.
  • Only Android and Desktop targets are set up currently.
  • I'm not sure if I'm setting -Xjvm-default=all properly.
  • I migrated tests from Truth to kotlin.test, but that API is pretty basic. Now using assertk.

@DSteve595 DSteve595 requested a review from saket May 15, 2023 16:31
@saket saket force-pushed the trunk branch 2 times, most recently from 18b3c14 to 202b5e4 Compare May 15, 2023 16:36
Copy link
Owner

@saket saket left a comment

Choose a reason for hiding this comment

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

This is amazing. I'm not familiar with publishing of multiplatform libraries at all. Will that automatically work with https://vanniktech.github.io/gradle-maven-publish-plugin?

@DSteve595
Copy link
Collaborator Author

DSteve595 commented May 15, 2023

Will that automatically work with https://vanniktech.github.io/gradle-maven-publish-plugin?

Kotlin Multiplatform has its own decently robust publishing support. Between that and AGP's recently-good publishing support, I haven't used the vanniktech plugin in a long time. It does say it supports Kotlin Multiplatform fwiw. Can't say for sure, though I can push to mavenLocal and see what happens.

@DSteve595
Copy link
Collaborator Author

DSteve595 commented May 15, 2023

Regarding publishing: Publishing works after specifying the variant to publish, making that change now.

@DSteve595 DSteve595 requested a review from saket May 15, 2023 18:14
Copy link
Owner

@saket saket left a comment

Choose a reason for hiding this comment

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

LFG!

@@ -48,6 +53,8 @@ androidx-activity = { module = "androidx.activity:activity-compose", version.ref
androidx-test-ktx = "androidx.test:core-ktx:1.5.0"
androidx-test-rules = "androidx.test:rules:1.5.0"
androidx-test-junit = "androidx.test.ext:junit-ktx:1.1.5"
androidx-compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "androidx-compose-compiler" }
# TODO remove compose libs in favor of declaring via jetbrains compose plugin
Copy link
Owner

Choose a reason for hiding this comment

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

Can you share more about this?

Copy link
Collaborator Author

@DSteve595 DSteve595 May 17, 2023

Choose a reason for hiding this comment

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

Jetbrains Compose has its own version (current latest 1.4.0), and that comes with a "blessed" set of versions for each of the Compose libraries. Those libraries are exposed via special dependency accessors. They look like:

dependencies {
  implementation(compose.ui)
  implementation(compose.material)
}

While it's totally possible to use arbitrary versions rather than the ones specified by the plugin, I went for the safe option of using the plugin's. Analogous to using the Compose BOM rather than specifying each library version individually.

If Telephoto totally adopts multiplatform, this TODO suggests to remove all the specific Compose library versions, in favor of fully using the plugin to add them as dependencies.

In the meantime, this split means that modules that use multiplatform could be using different versions of Compose libraries from those that use kotlin-android.

Copy link
Owner

Choose a reason for hiding this comment

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

Got it, thanks for explaining!

compilerOptions.configure {
freeCompilerArgs.addAll(
"-Xcontext-receivers",
"-Xjvm-default=all", // TODO IDE complains this isn't set (transformableState.kt). is it working?
Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No change, IDE still complains.

Copy link
Owner

Choose a reason for hiding this comment

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

Sigh okay. Let's get this PR merged for now. We can continue looking for a fix afterwards.

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