Skip to content

Build failure when hyphen(-) is used in @Named value e.g @Named("ricky-morty") #245

Closed
@kibettheophilus

Description

@kibettheophilus

Describe the bug
When a hyphen is used in a named value, it causes compilation failure. This seems to have been introduced from version2.0.0-RC1 since it is working the previous versions.

To Reproduce
Steps to reproduce the behavior:
This can be reproduced by adding hyphen to your @Named values e.g @Named("ricky-morty") which produces the error below:

e: [ksp] --> Missing Definition for property 'rickyMortyClient : io.ktor.client.HttpClient_Q_ricky-morty' in 'com.theophiluskibet.remote.api.CharactersApi'. Fix your configuration: add definition annotation on the class.
e: Error occurred in KSP, check log for detail
e: file:///Users/theophiluskibet/AndroidStudioProjects/koinplayground/core/remote/build/generated/ksp/debug/kotlin/org/koin/ksp/generated/KoinMeta-eabe9a52.kt:8:80 Expecting a top level declaration
e: file:///Users/theophiluskibet/AndroidStudioProjects/koinplayground/core/remote/build/generated/ksp/debug/kotlin/org/koin/ksp/generated/KoinMeta-eabe9a52.kt:8:81 Expecting a top level declaration
e: file:///Users/theophiluskibet/AndroidStudioProjects/koinplayground/core/remote/build/generated/ksp/debug/kotlin/org/koin/ksp/generated/KoinMeta-eabe9a52.kt:9:53 Expecting a top level declaration
e: file:///Users/theophiluskibet/AndroidStudioProjects/koinplayground/core/remote/build/generated/ksp/debug/kotlin/org/koin/ksp/generated/KoinMeta-eabe9a52.kt:9:54 Expecting a top level declaration
[ksp] --> Missing Definition for property 'rickyMortyClient : io.ktor.client.HttpClient_Q_ricky-morty' in 'com.theophiluskibet.remote.api.CharactersApi'. Fix your configuration: add definition annotation on the class.

I have a repdrocucer project - Koin Playground

  • master branch - this builds successfully because I have renamed the value by removing the hyphen i.e @Named("ricky_morty")
  • qualifier-bug branch - this fails beacuse the Named value has a hyphen i.e @Named("ricky-morty")

Expected behavior
The project should build successfully when I upgrade to version 2.0.0-RC1+

Koin project used and used version (please complete the following information):
[e.g]:

  • koin-core version 4.0.3-Beta1
  • koin-annotations version 2.0.0-RC1+

Additional moduleDefinition

  • This happens because during KoinMetaData generation, a class names and function names gets an hyphen which are not Kotlin conventions hence the failure e.g
.....
@MetaDefinition("com.theophiluskibet.remote.di.provideRickyMortyClient")
public class KoinMeta_ComTheophiluskibetRemoteDiProvideRickyMortyClient_Q_ricky-morty
public class KoinMeta_IoKtorClientHttpClient_Q_ricky-morty
.....

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:issueSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions