-
Notifications
You must be signed in to change notification settings - Fork 29
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
Annotations #178
Comments
I never thought about this use case to be honest. As a quick workaround, I'd suggest you change the default As a second, you can use the I think I craft a quick PR to change this, so you'll able to customize the final output yourself. |
It shouldn’t be needed.
But with kotlin removing package names.
I don’t see an alternative.
…On Mon, 16 Sep 2024 at 12:22, Guillermo Mazzola ***@***.***> wrote:
I never thought about this use case to be honest.
As a quick workaround, I'd suggest you change the default BuildConfig
name for each class to something that is unique.
As a second, you can use the buildConfig.generator API to set your own
generator, the issue is that it would be pretty much useless as you'll need
to fully implement it yourself. Currently both Kotlin and Java generators
are final as they are (necessary) data classes.
I think I craft a quick PR to change this, so you'll able to customize the
final output yourself.
—
Reply to this email directly, view it on GitHub
<#178 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABK3WZP5TRI3G5RBJUFT2TLZW2WP5AVCNFSM6AAAAABOI6CEB6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJSGUZDOOBTGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Released as |
You can check an example of how to do it here: buildConfig {
generator = object : BuildConfigKotlinGenerator() {
override fun adaptSpec(spec: TypeSpec) = spec.toBuilder()
.addAnnotation(AnnotationSpec.builder(ClassName.bestGuess("kotlin.js.JsName"))
.addMember("name = %S", spec.name!!)
.build())
.build()
} As it's a very concrete use case, I'm not going to document on the readme. |
thanks |
Hi,
Is there a way to add annotations ?
UseCase:
use in kotlin multiplatform project with multiple modules.
I generate a BuildConfig for each module.
Kotlin (for some reason I don't understand and disagree with) generates javascript files that ignore all package names.
thus the typescript file that is generated contains multiple 'BuildConfig' classes.
I figure I can fix that by adding an '@JsName' annotation to the generated BuildConfig class that adds something unique.
(of course what I really want is that JS code generated by kotlin includes the namespaces, but that is an argument I am having with Kotlin)
The text was updated successfully, but these errors were encountered: