Hey folks! I was wondering if anyone had a rough i...
# squarelibraries
m
Hey folks! I was wondering if anyone had a rough idea of the timeline for Anvil to support kotlin 2. We use Anvil at snapchat and are in the process of getting everything in place for the kotlin 2 upgrade. From what I've read there are workarounds to get this with KSP, but since our repo uses component merging it seems we have no choice but to stick to kotlin 1.9 I understand that providing an exact timeline can be hard, and I apologize for bugging your team about it, but if you have any rough estimate to provide that would be super helpful for us to plan appropriately Oh and thanks for all the great work you do on open source libraries! Always been a big fan
If that helps!
m
Hey @shaktiman_droid, thanks for the quick reply, and happy NYE! I've seen the roadmap before, which I appreciate you folks publishing. I was curious though if you folks have any rough timelines on when you aim to have kotlin 2 support If you don't I would understand, but if there was some info you could share there it would be very helpful for our team when it comes to planning our kotlin upgrade
s
Apologies for the confusion but I don't work at Square. I noticed the link and shared here wondering if you had seen that or not.
πŸ‘ 1
j
Sorry for the delay here as I was OOO at the time, just wanted to confirm that ^ is still accurate. K2 support is something the team is actively working on but isn't expected to be ready for at least a few months. It's also worth delineating Kotlin 2.0 from the K2 compiler here in case you primarily care about upgrading to the latest Kotlin releases. Although K2 support is a ways off still, we should have a Kotlin 2.0 compatible release soon. You may also be able to use Anvil 2.5.0 with Kotlin 2.0 in your project for now; we haven't found any incompatibilities between them in our internal projects (at least up to Kotlin 2.0.21).
πŸ‘ 1
m
I see, so you're saying that for some projects, kotlin language level 2.0 should work now with Anvil 2.5.0. Otherwise, a more robust kotlin 2.0 related release is coming out soon Then the K2 compiler compatibility changes are further down the road, at least a few months
j
Yup that sounds right! And when you're upgrading your Kotlin version, the K2 compiler will be enabled by default but can be disabled by setting
compilerOptions.languageVersion
back to
KotlinVersion.KOTLIN_1_9
in Gradle
m
Do you mean
can
be disabled by doing xyz?
Also we use bazel, so slightly different but I can probably find a way to pass that in
πŸ‘ 1
But I thought your first message was saying that anvil should work (or will soon) with
languageLevel = 2.0
, is that not what you meant? From that message I thought you meant we should be able to set language to 2.0 and then set something like
use_k2 = false
j
Do you mean
can
be disabled by doing xyz?
Oops, yes that was a typo πŸ˜…
blob no problem 1
Sorry, yea unfortunately language version is an overloaded term now which is why I've tried to add clarifying details in my messages. The dependency language version and compiler language version can be different
To try and make my previous message clearer: You should be able to upgrade to the Kotlin 2.0 release but use compiler language version 1.9 (aka K1) with Anvil 2.5.0 or at least the next release where we will actually be targeting Kotlin 2.0. By default, all Kotlin 2.0 releases default to using compiler language version 2.0 (aka K2).
One other detail is I believe the
use_k2
property was deprecated as of Kotlin 2.0 and configuring the compiler's language version is now the way to enable/disable k2
πŸ‘ 1
m
Ah I see, okay that's what I was noticing in my tests as well. I can only get things to compile if I set languageLevel = 1.9
πŸ‘ 1
In this next release (the kotlin 2.0, not K2 one) would we still have to set languageLevel =1.9? It sounds like that
Then we'd have to wait till the further out K2 fix for us to do languageLevel = 2.0, correct?
Also sorry if my questions are kind of redundant haha, I'm still a bit new to compiler stuff
j
In this next release (the kotlin 2.0, not K2 one) would we still have to set languageLevel =1.9? It sounds like that
Then we'd have to wait till the further out K2 fix for us to do languageLevel = 2.0, correct
Yea that is correct
πŸ‘ 1
No worries at all!
m
Sounds good, thanks so much for your patience explaining all this! Also, I seem to recall Anvil only officially supports gradle and due to that bazel use cases aren't as common. If you folks want more visibility on issues related to bazel I can share things with you as I find them. But if you're not concerned at all with bazel that's fine too. Just wanted to offer in case that'd be helpful!
❀️ 1
j
Aye that's correct; historically Anvil's development has been pretty focused on Square's internal projects and we still use Gradle for everything Android-related. Bazel isn't something we currently plan on adding direct support for but I appreciate you offering! Maybe one day πŸ˜„
πŸ‘ 1
Also wanted to share a heads-up that I just released https://github.com/square/anvil/releases/tag/v2.5.1 (for the Kotlin 2.0 support)
πŸ™Œ 1