MetroPluginExtension

abstract class MetroPluginExtension @Inject constructor(compilerVersion: Provider<KotlinToolingVersion>, layout: ProjectLayout, objects: ObjectFactory, providers: ProviderFactory)(source)

Constructors

Link copied to clipboard
@Inject
constructor(compilerVersion: Provider<KotlinToolingVersion>, layout: ProjectLayout, objects: ObjectFactory, providers: ProviderFactory)

Types

Link copied to clipboard
abstract class CompilerOptionsHandler @Inject constructor(objects: ObjectFactory)
Link copied to clipboard
abstract class InteropHandler @Inject constructor(objects: ObjectFactory)

Properties

Link copied to clipboard

Automatically adds Metro runtime artifact dependencies.

Link copied to clipboard
@DangerousMetroGradleApi(message = "This could break Metro's compatibility layer!")
val compilerVersion: Property<String>

Override the Kotlin compiler version Metro operates with.

Link copied to clipboard

Compiler version aliases mapping fake IDE versions to their real compiler versions.

Link copied to clipboard

Treats @Contributes* annotations, except @ContributesTo, as implicit @Inject annotations.

Link copied to clipboard
val debug: Property<Boolean>

Enables debug logging for this project.

Link copied to clipboard

Severity for desugared Provider<T> function types. Prefer () -> T.

Link copied to clipboard

Build-output rendering mode for diagnostics. See the docs on DiagnosticsRenderMode for details.

Link copied to clipboard

Generates Metro-native Circuit bindings for @CircuitInject classes and functions. Metro will generate Ui.Factory and Presenter.Factory implementations for @CircuitInject-annotated classes and functions.

Link copied to clipboard
val enabled: Property<Boolean>

Enables Metro for this project.

Link copied to clipboard

Treats () -> T as a provider type.

Link copied to clipboard

Shards generated binding graphs. Enabled by default.

Link copied to clipboard

Treats java.lang.Class and kotlin.reflect.KClass as interchangeable in multibinding map key types, matching Kotlin's own annotation compilation behavior. This only applies to map keys because these are the only scenario where annotation arguments are materialized into non-annotation code (i.e. @ClassKey(Foo::class) -> Map<Class<*>, V>).

Link copied to clipboard

Checks klib parameter qualifiers.

Link copied to clipboard

Enables Kotlin version compatibility checks. Defaults to true or the value of the metro.version.check Gradle property.

Link copied to clipboard

Enables bytecode/IR tracing for binding injections using androidx.tracing.

Link copied to clipboard

Uses SwitchingProviders for deferred class loading. This reduces graph initialization time by deferring bindings' class init until the binding is requested.

Link copied to clipboard
@DelicateMetroGradleApi(message = "Top-level function injection is experimental and does not work yet in all cases. See the kdoc.")
val enableTopLevelFunctionInjection: Property<Boolean>

Enables injection for top-level functions. See the kdoc on Inject for more details.

Link copied to clipboard
@DangerousMetroGradleApi(message = "This could break analysis in your IDE if you force-enable!")
val forceEnableFirInIde: Property<Boolean>

Enables Metro FIR extensions in the IDE even when the compat layer cannot be determined.

Link copied to clipboard

Generates assisted factories automatically for injected constructors with assisted parameters. See the kdoc on AssistedFactory for more details.

Link copied to clipboard

Generates metadata-visible hidden classes in IR instead of FIR when supported by the Kotlin compiler.

Link copied to clipboard

Generates contribution hints in IR.

Link copied to clipboard
@DelicateMetroGradleApi(message = "FIR contribution hint generation is experimental and does not work yet in all cases. See the kdoc.")
val generateContributionHintsInFir: Property<Boolean>

Generates contribution hints in FIR. Requires generateContributionHints to be true.

Link copied to clipboard

Generates top-level contribution provider classes with @Provides functions instead of nested binding containers with @Binds callables for @ContributesBinding, @ContributesIntoSet, and @ContributesIntoMap.

Link copied to clipboard
Link copied to clipboard

Severity for interop annotations that use positional arguments instead of named arguments.

Link copied to clipboard
val keysPerGraphShard: Property<Int>

Maximum binding keys per graph shard when sharding is enabled. Default is 2000. Must be > 0.

Link copied to clipboard
val maxIrErrors: Property<Int>

Maximum errors to report before exiting IR processing. Default is 20. Must be > 0.

Link copied to clipboard

Severity for non-public @Contributes* declaration diagnostics. This includes declarations that are internal, private, protected, nested in non-public classes, etc.

Link copied to clipboard

Optional binding behavior. Default is OptionalBindingBehavior.DEFAULT.

Link copied to clipboard

Patches klib parameter qualifiers to work around a kotlinc bug. Only applies when enableKlibParamsCheck is also enabled.

Link copied to clipboard

Severity for public scoped-provider diagnostics. See the kdoc on Provides for more details.

Link copied to clipboard
@DelicateMetroGradleApi(message = "This should only be used for debugging purposes and is not intended to be always enabled.")
val reportsDestination: DirectoryProperty

If set, the Metro compiler will dump verbose report diagnostics about resolved dependency graphs to the given destination. Outputs are per-compilation granularity (i.e. build/metro/main/...).

Link copied to clipboard
val statementsPerInitFun: Property<Int>

Maximum statements per init method when chunking field initializers. Default is 25. Must be > 0.

Link copied to clipboard
@DelicateMetroGradleApi(message = "Contribution hint generation does not work yet in all platforms on all Kotlin versions. See the kdoc.")
val supportedHintContributionPlatforms: SetProperty<KotlinPlatformType>

Sets the platforms for which contribution hints will be generated. If not set, defaults are computed per-platform and per Kotlin version based on known compatible combinations.

Link copied to clipboard
val traceDestination: DirectoryProperty

If set, the Metro compiler will dump compiler trace information to the given destination. Outputs are per-compilation granularity (i.e. build/metro-traces/main/...).

Link copied to clipboard

Severity for unused graph inputs, such as factory parameters and directly included binding containers that are not used by the graph.

Link copied to clipboard

Suggests moving @Inject/@AssistedInject to the class when it has only one constructor. Enabled by default.

Functions

Link copied to clipboard

Configures Metro options for misc compiler options that don't necessarily warrant dedicated API controls.

Link copied to clipboard

Configures interop to support in generated code, usually from another DI framework.