glide icon indicating copy to clipboard operation
glide copied to clipboard

Feature request: Support KSP

Open davidjwiner opened this issue 3 years ago • 22 comments

For Kotlin projects, Glide currently makes use of KAPT. This is generally quite slow since it requires generating Java stubs before the annotation processing step.

KSP offers an alternative to this by making it easier for annotation processors like Glide to more directly use Kotlin's compiler plugin infrastructure. Based on initial benchmarks, using KSP can speed up build times by as much as 2x.

davidjwiner avatar Feb 01 '21 20:02 davidjwiner

"The reduction of build times is only applicable if there are no other processors that use KAPT." source: https://developer.android.com/jetpack/androidx/releases/room#2.3.0-beta02

Meaning: if you have Glide in your project, KSP won't bring any benefits until Glide support is ready.

They told us to exercise social pressure. Here it is :)

pvegh avatar May 04 '21 08:05 pvegh

More social pressure!

joshschriever avatar May 19 '21 17:05 joshschriever

Unfortunately the API for KSP is not compatible with the java equivalent. We're going to have to do some non-trivial abstracting, mostly of the methods here: https://github.com/bumptech/glide/blob/a8c24c63c195306f82e36775d9f08f23c72c700e/annotation/compiler/src/main/java/com/bumptech/glide/annotation/compiler/ProcessorUtil.java#L57. The KSP team took a stab at this and was able to come up with a prototype, but wasn't able to make it production ready.

Since Glide is an open source project, anyone is welcome to contribute. The best way to apply social pressure is to of course spend your time on the improvement :)

This isn't completely straightforward, so if someone is interested, please reach out to me directly before you get too far so we can talk about it.

sjudd avatar May 19 '21 19:05 sjudd

Oh this also appears to be blocked internally due to lack of support where Glide is hosted, so we'll need more work from the KSP team before it's possible to submit anything here.

sjudd avatar May 20 '21 20:05 sjudd

Oh this also appears to be blocked internally due to lack of support where Glide is hosted,

what does that mean?

eman1986 avatar Nov 26 '21 02:11 eman1986

Any updates on this?

anjalsaneen avatar Dec 14 '21 15:12 anjalsaneen

Happy new year 2022 everyone! It's been almost a year since the last Glide update. Any updates on the KSP support status? It's the only dependency that blocks my project migration to KSP.

ArtemKleinschmidt avatar Jan 05 '22 08:01 ArtemKleinschmidt

Happy new year 2022 everyone! It's been almost a year since the last Glide update. Any updates on the KSP support status? It's the only dependency that blocks my project migration to KSP.

me2

mistletoe5215 avatar Jan 20 '22 09:01 mistletoe5215

Happy new year 2022 everyone! It's been almost a year since the last Glide update. Any updates on the KSP support status? It's the only dependency that blocks my project migration to KSP.

me2

me2

Ezrael2k5 avatar Jan 28 '22 14:01 Ezrael2k5

Happy new year 2022 everyone! It's been almost a year since the last Glide update. Any updates on the KSP support status? It's the only dependency that blocks my project migration to KSP.

me2

me2

me2

bennyhuo avatar Feb 08 '22 02:02 bennyhuo

Happy new year 2022 everyone! It's been almost a year since the last Glide update. Any updates on the KSP support status? It's the only dependency that blocks my project migration to KSP.

me2

me2

me2

me2

alvin96 avatar Feb 15 '22 05:02 alvin96

Hi guys, any updates on this? It's the only dependency blocking our migration to KSP too :(

fertwo avatar Mar 10 '22 01:03 fertwo

hi all,as u know, glide-parent project is a project based on java ,i've released a version of glide ksp jar which using kotlin language and ksp to maven central repository,named io.github.mistletoe5215:glide-ksp:1.0.0,any one interested can have a try.It can satisfied my own project's needs.However ,i still have one problem:can't find classes with GlideModule annotation in library or jar/aar dependcies ,therefore,i just wrote these class qualifiedNames in ksp options's arg,hope some master can help me @sjudd ..@A@,the following is my glide-ksp project see link

mistletoe5215 avatar Mar 17 '22 07:03 mistletoe5215

Glide is blocking us from migrating from KAPT to KSP too

trevorhackman avatar May 13 '22 23:05 trevorhackman

KSP apparently continues not to be available in the Google repo where Glide lives, which will complicate a migration. We could still accept contributions towards adding a second processor externally. It'll require some coordination, so please let me know if you're interested in working on it.

sjudd avatar May 13 '22 23:05 sjudd

I found that Kotlin seems going to abandon KAPT in new K2 compiler: https://youtrack.jetbrains.com/issue/KT-52284

Change Log here: https://github.com/JetBrains/kotlin/releases/tag/v1.7.0-RC2

techwn avatar Jun 04 '22 09:06 techwn

Please be careful what information you spread. KAPT is currently not supported in the experimental K2. It is still on the roadmap for beta. https://youtrack.jetbrains.com/issue/KT-52604/Release-K2-Beta

ephemient avatar Jun 04 '22 10:06 ephemient

Dagger2 are very close to support ksp

Very close? Please, could you share the source of this statement?

neworld avatar Jun 10 '22 08:06 neworld

Dagger2 are very close to support ksp

Very close? Please, could you share the source of this statement?

Looks like there is still quite a lot of work to do https://github.com/google/dagger/issues/2349

mrmike avatar Jun 10 '22 09:06 mrmike

they're at least closer than glide is, glide doesn't even seem to be trying, they just said it's not easy and asked for volunteers to help with it.

elomonaco avatar Jun 10 '22 13:06 elomonaco

One more vote for this

kroussevrb avatar Jun 24 '22 06:06 kroussevrb

Plan for now is to support:

  1. AppGlideModules
  2. LibraryGlideModules
  3. Excluding LibraryGlideModules from an AppGlideModule.

We will not supported Glide's generated API (Extensions, GlideApp, GlideRequests, GlideRequest). We will not support modules registered via AndroidManifests.

This will allow people to use KSP to configure Glide and register integration libraries while substantially minimizing the amount of code that needs to be duplicated in the KSP processor. Users that want to use the full generated API can continue to use the Java annotation processor.

I'm not sure how many people today use GlideApp/GlideRequests/GlideRequest without an Extension today. We did recommend people do so for a while (and may still) in our documentation. If we don't generate those in KSP, people will have some migration work to do to use KSP. It's pretty trivial because the APIs will be identical, but a large codebase may have to change a lot of callsites to switch from the generated API back to the underlying classes (Glide, RequestManager, RequestBuilder). If a lot of you do this, please let me know here. We could consider trying to generate these classes to ease the migration path while still not supporting Extensions.

sjudd avatar Jul 14 '22 20:07 sjudd

Launched in 4.14.0 (though you'll want 4.14.2+)

sjudd avatar Oct 19 '22 00:10 sjudd