-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
feat: @ComponentScan glob support #131
base: main
Are you sure you want to change the base?
Conversation
This commit introduces a new Kotlin file, GlobToRegex.kt, which provides utilities for converting glob patterns to regular expressions, primarily for matching package names in JVM projects.
Suffix and prefix wildcard pattern like are now supported
Now `com.example.*.service` does ot match `com.example.service`.
Hello, great addition. Could you add some local unit tests to help be sure we cover those regex? Thanks 🙏 |
Of course, since all tests are located in modules within the |
Summary
This PR enhances the
@ComponentScan
annotation in Koin Annotations to support glob patterns. Currently,@ComponentScan
only allows specifying a single, exact package name per Koin module. With this change, developers can use wildcards (*
and**
) to scan multiple packages or subpackages in a more flexible and concise way.Motivation
In modern, modular JVM applications, components (like services, repositories, or utilities) are often spread across multiple subpackages. The current
@ComponentScan
requires developers to either:By supporting glob patterns, we allow developers to organize their code more naturally without compromising on Koin's autowiring capabilities.
Implementation
Added
GlobToRegex.kt
utility:*
(single-level) and**
(multi-level) wildcards.Modified
KoinMetaDataScanner
andKoinMetaData
:Tests
Examples
Before:
After:
However we can still use: