Closed passy closed 4 months ago
@passy @PropDefault
does not work for which cases? Is there a branch with Kotlin sample available?
@pavlospt I'm working on fixing that today. I think Pasquale's Kotlin sample could use this in a spot.
@passy Have you tried @get:PropDefault val something = 1f
for example ?
@pavlospt Sadly, that generates even worse code for us at the moment. I've got a work-around ready with a long-ish explanation on the commit which should land probably tomorrow.
Ok, great! Will wait to check that commit tomorrow :) Please ping it here as well in case I miss it :P
@pavlospt As if you'd ever miss a commit! 😜
@passy My colleagues usually say the same thing, no wonder why 😂
@passy What kind of bugs do you experience with kapt? If you can reproduce something going bad, please submit the issue to kotl.in/issue, and we will fix it shortly.
@yanex Hey! Thanks for commenting here. :)
Sadly, the main problem for us has exactly been reproducible. Everyone on our team who's worked with this has found themselves in a situation where compilation would fail for seemingly random reasons and only clearing the caches would help.
In particular, we've seen NonExistentClass
in stubs appear at times. Again, one ./gradlew clean
and it would be gone, but it can lead to some quite frustrating development cycles where you think you made a mistake in the codegen, but it turns out to be non-determinism in kapt.
If I see a reproducible case, I will definitely send it your way. :)
I would add that the main issue there is that gradle clean and rebuild makes the development cycle really too slow 😢
@passy Please check if you use the new version of kapt (aka kapt3, you can find the setup instructions here https://kotlinlang.org/docs/reference/kapt.html).
The original kapt definitely had architectural problems that led to random NonExistentClass
errors, that is why it is deprecated now (and will be removed in Kotlin 1.2.20). If you experience NonExistingClass
errors with apply plugin: 'kotlin-kapt'
, then it is something new.
@pasqualeanatriello Kotlin incremental compilation does not support changes in Java files yet. So whenever the annotation processor generates the different .java
source, Kotlin recompiles much more files that it is needed.
Hopefully, we are already working on this, and we hope things will become much better very soon.
If you experience NonExistingClass errors with apply plugin: 'kotlin-kapt', then it is something new.
Yes, it was with kotlin-kapt
. The old one didn't seem to work for us at all. We rely on annotated source files being able to reference the generated files based on them. It seemed like this wasn't support with the old kapt, but works with the new.
I didn't know about the correctErrorTypes = true
option, though. Perhaps that could help us track this down if it should come up again.
What's the status on this? Is it feasible to use litho with Kotlin in a real life project currently?
Hey @kar , you can find Kotlin-powered samples inside the repository! Check sample-barebones-kotlin
and sample-kotlin
for more details :)
@passy I think it can be closed and also remove the IMPORTANT
notice from this doc: https://github.com/facebook/litho/blob/master/docs/_docs/getting-started/gradle-kt.md
I'll update the comment. As long as we don't use it in production internally, I think it's best to keep the note there to set the right expectations.
@passy sure sounds reasonable!
I made a bad judgement call of adopting https://github.com/vinc3m1/litho-kotlin, but it had really nice results. I hope you guys bring it back as an official DSL sooner rather than later.
Will not close this one for now, but wanted to bring this to your attention:
https://github.com/facebook/litho/blob/master/sample-kotlin/src/main/kotlin/com/facebook/samples/litho/kotlin/lithography/components/FavouriteButton.kt
To use that you need to add litho-core-kotlin
and maybe litho-widget-kotlin
to your build.gradle
file.
cc @yschimke
This issue is to keep track of remaining issues and where applicable work-arounds when using Litho with Kotlin.
Issues
object
s for specs.@JvmStatic
.@PropDefault
doesn't work.@PropDefault
requires@JvmField
annotation.Other Gotchas
kapt
is a pig. There seem to be a bunch of invalidation bugs that force you to clean your cache and rebuild.NonExistentClass
shows up in random places. Again, this appears to be akapt
bug and the best workaround for now appears to be./gradlew clean
.Future work
We should consider generating Kotlin code to fully leverage the new language features like data classes, allow for Anko-like DSLs and get rid of builders.