ComponentScan

annotation class ComponentScan(val value: String = [])

Gather definitions declared with Koin definition annotation. Will scan in current package or with the explicit packages names. For scan current package use empty value array or empty string.

The value parameter supports both exact package names and glob patterns:

Exact package names (without wildcards):

  • Example: com.example.service

    • Scans all classes in the specified package and its subpackages.

    • This is equivalent to the glob pattern com.example**.

Glob patterns:

  1. Multi-level scan including the root package:

    • com.example** scans classes in com.example as well as in all its subpackages.

  2. Multi-level scan excluding the root package:

    • com.example.** scans only the subpackages of com.example, and does not include classes directly in com.example.

  3. Single-level wildcard (*):

    • Example: com.example.*.service

      • Matches exactly one level in the package hierarchy.

      • For instance, it matches com.example.user.service or com.example.order.service, but does NOT match com.example.service or com.example.user.impl.service.

Wildcards can be combined at any level:

  • Example: com.**.service.*data

  • Matches any package where, at some level, a "service" subpackage contains a package ending with "data".

  • Example: com.*.service.**

  • Scans all classes in any subpackage of a package matching com.<anything>.service.

Parameters

value

The packages to scan. Specify either an exact package name or a glob pattern. If left empty, the package of the annotated element is used.

Properties

Link copied to clipboard
val value: Array<out String>