hey gang - in doing some searching I haven't seen ...
# ksp
m
hey gang - in doing some searching I haven't seen this topic broached in a bit. is there any straightforward recipe for combining KSP with an android library? I've been trying to cram the
com.android.library
plugin into the KSP Quickstart's
test-processor
module without much luck
e
Generally processor libraries shouldn’t/can’t also be android libraries. At least that was the story with java annotation processors and I imagine KSP is similar
if you need an Android type you can look it up by fully qualified name in KSP at runtime
m
yeah, that makes sense - I don't necessarily want to make the processor lib an Android lib, but was hoping to access the android libs from my KSP processor to generate code that adds a certain decorator to android library classes, then sticks that resulting code into a different module that is an actual library
and it occured to me I didn't know how to access the Android classes in my project without using either the
android
or
com.android.library
gradle plugins
w
do you have a specific example of what you are trying to access?
m
I'd like to use KotlinPoet to generate some convenience methods around `DevicePolicyManager`'s member functions and stick them inside a different module that can be compile as a jar or aar. Somewhat similar to what the KSP Quickstart does, just concerned with specific Android based classes I'm interested in
w
not sure if this is helpful, but in my annotation processor, i create
android.os.Bundle
extension functions with the following:
Copy code
private val bundleClassName = ClassName("android.os", "Bundle")
val funBuilder = FunSpec.builder("someExtensionMethod")
    .receiver(bundleClassName) // bundle is the receiver (extension function)
👍 1
this is getting more into ktpoet, but the example here is that we don’t need to be an android library to do that
m
this is helpful - part of what I'm trying to figure out what the right way to do this is 😄
but I'm trying to inspect the parameters, etc, that the individual functions are invoked with
w
i don’t know that an annotation processor is aware of those things
👌 1
m
thanks for the advice william, I appreciate it
🇳🇵 1
all this said while it's not really leveraging KSP apart form being it's own gradle plugin, was able to get what I was after by adding the dependency of :)
Copy code
implementation(files("/Users/matthew.laser/Library/Android/sdk/platforms/android-30/android.jar"))