-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add no-op JVM target #626
Add no-op JVM target #626
Conversation
… with other targets
This reverts commit bc1056e.
7d88b05
to
dd9ad8c
Compare
Build failed due to
I thought that these are generated during the build, will run locally and add. |
This may have changed/improved, but I thought historically having a JVM and Android target in the same module would confuse Gradle on the consumer side? In other words, would an Android app project be able to consume Kable if it had both an Android target and a (no-op) JVM target? How would it know to use the Android when both are available? If you have a chance (if not, then I'll try to find some time) to test these changes in the SensorTag sample app to ensure it doesn't break Android app consumers. If it does break Android consumers, then I believe we'll have to introduce a new |
TBH I haven't experienced this before. I thought it's handled by gradle. But good point
I tried it with SensorTag and it works as expected. Also, I tried it with a project that has iOS, android and desktop targets and it compiles and runs as expected for all of the platforms. After you comment I also did a sanity check with my android app that scanning and connecting to a BLE device works as before (without the no-op jvm impl). |
Awesome! Thanks for testing/validating! |
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.
Looks good to me.
Weighing in on the build issues re. having both jvm
and android
targets, I think I remember it being a problem specifically when there was a diamond hierarchy. If jvm-library
depends on kable
, android-library
depends on kable
, and your-android-app
depends on both jvm-library
and android-library
, problems show up.
Supporting JVM doesn't automatically break anything so I'm cool with this going in, but it does leave some room to shoot yourself in the foot.
@@ -0,0 +1,6 @@ | |||
package com.juul.kable | |||
|
|||
public fun jvmNotImplementedException(): Nothing = throw NotImplementedError( |
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.
Can this be internal
?
public fun jvmNotImplementedException(): Nothing = throw NotImplementedError( | |
internal fun jvmNotImplementedException(): Nothing = throw NotImplementedError( |
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.
No, if it's internal, the compiler gives error about the visibility.
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 presume the error is related to other modules not being about to access it?
In that case, can we make it internal
and duplicate the function in any module that uses it?
That way we aren't exposing a new function on the public API.
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.
Good point. Actually, I miss understood the error. It seemed relevant but actually it was hiding a missing impl in the exceptions module! Made this internal and also added the implementation for the jvm target for the IOException.
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.
Saw your revert, makes sense, thank you. Don't know why building locally failed but passing here in GHA. Will try to understand.
Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
@twyatt anything more to look into? |
Apologies for the delay. Looks good aside from one last comment I left re: removing the exception function from the public API. |
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.
Looks great!
I'll do some final testing this weekend and get it merged/released.
Thanks @konpach!
Relates Issue: #380
Context: Until library gets a proper implementation for jvm targets we want to allow the usage of the library in supported targets along with jvm. Currently is not possible to compile shared if jvm target exists (as there is no corresponding implementation in kable).
Solution: Provide an empty implementation that throws runtime exceptions for kable for jvm target.