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

Migrate java.io.File Usage to Kotlin Multiplatform-Compatible Abstraction #302

Closed
takahirom opened this issue Apr 17, 2024 · 5 comments · Fixed by #368
Closed

Migrate java.io.File Usage to Kotlin Multiplatform-Compatible Abstraction #302

takahirom opened this issue Apr 17, 2024 · 5 comments · Fixed by #368

Comments

@takahirom
Copy link
Owner

takahirom commented Apr 17, 2024

We're using java.io.File which is not compatible with Kotlin Multiplatform (KMP). We need to replace it with a KMP-friendly alternative to achieve cross-platform compatibility like iOS

github-merge-queue bot pushed a commit to slackhq/circuit that referenced this issue Apr 21, 2024
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
|
[io.github.takahirom.roborazzi](https://togithub.com/takahirom/roborazzi)
| plugin | minor | `1.12.0` -> `1.13.0` |
|
[io.github.takahirom.roborazzi:roborazzi-junit-rule](https://togithub.com/takahirom/roborazzi)
| dependencies | minor | `1.12.0` -> `1.13.0` |
|
[io.github.takahirom.roborazzi:roborazzi-compose](https://togithub.com/takahirom/roborazzi)
| dependencies | minor | `1.12.0` -> `1.13.0` |
|
[io.github.takahirom.roborazzi:roborazzi](https://togithub.com/takahirom/roborazzi)
| dependencies | minor | `1.12.0` -> `1.13.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>takahirom/roborazzi (io.github.takahirom.roborazzi)</summary>

###
[`v1.13.0`](https://togithub.com/takahirom/roborazzi/releases/tag/1.13.0)

[Compare
Source](https://togithub.com/takahirom/roborazzi/compare/1.12.0...1.13.0)

##### Add experimental, minimal support for iOS in Compose Multiplatform

Roborazzi has supported Compose Desktop, but we hadn't yet supported
iOS, which could be a major use case for Compose Multiplatform.
Therefore, I have added support for iOS.
Now, you can record, compare, and verify just as you would with Android
support.

https://takahirom.github.io/roborazzi/compose-multiplatform.html#experimental-feature-ios-support


![ios_button_compare](https://togithub.com/takahirom/roborazzi/assets/1386930/2d7a8faf-f57f-4543-bade-b1aef82ed15a)

However, Roborazzi is fundamentally based on the JVM. Currently, we
offer only minimal features. If you are interested in helping to improve
these features, please take a look at these issues:

[takahirom/roborazzi#302
[takahirom/roborazzi#305

##### Changes Affecting Existing Support

To support iOS, we have made some dependency changes for Android and
Compose Desktop. I believe these changes will not affect existing
behavior. However, if you notice anything, please let me know.

All
Kotlin:
1.8.22 -> 1.9.21

dropbox/differ:
0.0.1 -> 0.0.2

##### Desktop Compose Version

Compose Multiplatform:
1.4.3 -> 1.6.1

##### What's Changed

- Add Minimal Compose Multiplatform iOS Support by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#301
- \[docs]Fix docs page by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#303
- \[docs]Fix docs by [@&#8203;takahirom](https://togithub.com/takahirom)
in
[takahirom/roborazzi#304
- Add roborazzi-painter ios file for building klib by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#306
- \[CI]Fix false positive diff in Roborazzi CI by using the same
platform for store and compare by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#307
- Remove unneeded jvm form compose ios by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#308
- Fix task and fix ios recording by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#310
- Fix iOS recording path by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#311
- Fix iOS golden path and report time logic by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#312
- Fix iOS comparison logic by
[@&#8203;takahirom](https://togithub.com/takahirom) in
[takahirom/roborazzi#313

**Full Changelog**:
takahirom/roborazzi@1.12.0...1.13.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMTMuMSIsInVwZGF0ZWRJblZlciI6IjM3LjMxMy4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
@eyedol
Copy link
Contributor

eyedol commented May 16, 2024

Did you have any library in mind for this? I see these io libraries are available for KMP.

  1. Okio
  2. korlibs
  3. Suparnatural FS
  4. kotlinx-io

Which do you think will be more appropriate for Roborazzi? If we agree on one, I don't mind picking this issue to work on. Let me know.

@takahirom
Copy link
Owner Author

@eyedol
Thank you for suggesting options.
Perhaps Okio and Kotlinx-io are good choices because of their user base. Many people use Okio for their network requests, and we don't want to disrupt their builds. Thus, I think Kotlinx-io is a good choice.

@RyuNen344
I apologize for the sudden contact, but you seem knowledgeable about Roborazzi and Okio. Could you share any opinions on this matter?

@eyedol
Copy link
Contributor

eyedol commented May 17, 2024

@takahirom thanks for your quick response. Yeah I think so too, kotlinx-io is a good choice to go with as it's an official library by Jetbrains. My only issue it's an experimental library and its APIs may change.

Note that the library is experimental, and the API is subject to change.

If it's not a concern, I guess we can run away with using it. And yes let's see what RyuNen344 says...

@RyuNen344
Copy link

RyuNen344 commented May 19, 2024

@takahirom
thanks for contacts me 😉

Since kotlinx-io is built upon Okio's implementation, both libraries should function with Roborazzi.
Here's a breakdown of their key features to help you decide:

kotlinx-io

  • Offers core functionalities like ByteString, Buffer, and Sink.
  • Provides a basic file system wrapper.

Okio

  • Includes all functionalities offered by kotlinx-io (ByteString, Buffer, and Sink).
  • Provides a more comprehensive file system wrapper.
  • Can access resource directories on KMP(also provides extensions for android asset directory)
  • Integrates seamlessly with java.io APIs, allowing easy use of encryption streams like CipherSink and CipherSource.
  • Implements hash functions (sha256, md5) on KMP, potentially useful for image file comparisons.

Roborazzi likely doesn't necessitate stream or encryption stream handling, so kotlinx-io might suffice for basic file I/O needs. If you foresee complex file operations or stream processing in the future, Okio offers a richer feature set.

Ultimately, the choice depends on your project's requirements. Both libraries are well-maintained by reputable organizations.

@eyedol
Copy link
Contributor

eyedol commented May 19, 2024

@takahirom I believe per @RyuNen344 comprehensive response, it's safe to say that we can use kotlinx.io as it has all that's needed for Roborazzi. Well, except for the fact that it's currently experimental and the API's might change. I guess we will cross that bridge when that happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants