-
Notifications
You must be signed in to change notification settings - Fork 250
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 new API to retrieve name of the current module to the Resolver #1015
Comments
Module names seem to be quite peculiar. When testing #1021, this is what I found: Given
include(":annotations")
include(":workload")
include(":test-processor")
This would produce the following module names:
So I wonder: Are these module names of interest or is it about something else? |
Any updates on this? |
Workaround: /**
* todo use `resolver.moduleName` when [https://github.com/google/ksp/issues/1015] is done
* @return gradle module name
*/
private fun moduleName(resolver: Resolver): String {
val moduleDescriptor = resolver::class.java
.getDeclaredField("module")
.apply { isAccessible = true }
.get(resolver)
val rawName = moduleDescriptor::class.java
.getMethod("getName")
.invoke(moduleDescriptor)
.toString()
return rawName.removeSurrounding("<", ">")
} |
note that this is highly implementation dependent, might break, and will not work for the K2 implementation of KSP. |
ResolverImpl
contains this info, but it is not exposed through theResolver
API. Maybe it is possible to enhance the API by addingmoduleName
property to Resolver?https://kotlinlang.slack.com/archives/C013BA8EQSE/p1649968377169569
The text was updated successfully, but these errors were encountered: