Skip to content
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

Scan more than one component at the time #182

Open
wants to merge 4 commits into
base: 2.0.0
Choose a base branch
from

Conversation

vivodikj
Copy link

@vivodikj vivodikj commented Oct 16, 2024

Summary

This PR create an option for add more packages in scanning component feature, inspired by this issue. With this change, developers can use new @ComponetsScan annotation with values parameter where they can add all needed packages. The original @ComponentScan annotations is 100% preserved and now can cooperate with new @ComponetsScan.

All tests still passes like a charm and new test passed without any problem.

Examples

Before

@Module(includes = [DataModule::class])
@ComponentScan("org.koin.sample.androidx.app")
class AppModule

@Module(includes = [CommonModule::class, RepositoryModule::class])
@ComponentScan("org.koin.sample.androidx.data")
internal class DataModule

After 1. variant

@Module(includes = [CommonModule::class, RepositoryModule::class])
@ComponentsScan(values = ["org.koin.sample.androidx.app", "org.koin.sample.androidx.data"])
class AppModule

After 2. variant

@Module
@ComponentsScan(values = [
    "org.koin.sample.androidx.app", "org.koin.sample.androidx.data",
    "org.koin.sample.androidx.repository", "org.koin.sample.android.library",
])
class AppModule

After 1. variant if we want scan actual package

@Module
@ComponentsScan(values = [
    "", "org.koin.sample.androidx.app", "org.koin.sample.androidx.data",
    "org.koin.sample.androidx.repository", "org.koin.sample.android.library",
])
class AppModule

After 2. variant if we want scan actual package

@Module
@ComponentsScan
@ComponentsScan(values = [
    "org.koin.sample.androidx.app", "org.koin.sample.androidx.data",
    "org.koin.sample.androidx.repository", "org.koin.sample.android.library",
])
class AppModule

NOTE:

If dev use @ComponentsScan or @ComponentsScan([]) or @ComponentsScan([""]) this will scan actual package like original @ComponentScan.

If dev add non existing or correct package name to @ComponentsScan values, the package will be ignored and nothing happens.

If dev add multiple package names to @ComponentsScan values, only one will be used and multiple package names error is not shown.

@arnaudgiuliani
Copy link
Member

let's go on branch v2 as it's a new feature / improvement proposal

@arnaudgiuliani arnaudgiuliani changed the base branch from 1.4.0 to 2.0.0 November 18, 2024 16:27
@arnaudgiuliani arnaudgiuliani added this to the 2.0 milestone Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants