Skip to content

Releases: ZacSweers/metro

0.8.2

04 Dec 21:11

Choose a tag to compare

  • Fix: Avoid JDK 21 List.removeFirst() call in the compiler artifact. That said, Metro's compiler may move to JDK 21+ in the future (note this is separate from the runtime JVM targets).
  • Fix: Fix accidental androidx.test transitive dependency in metrox-viewmodel-compose artifact.

What's Changed

Full Changelog: 0.8.1...0.8.2

0.8.1

04 Dec 03:31

Choose a tag to compare

  • New: Experimental support for Kotlin 2.3.20 dev builds. See the compatibility docs for tested versions.
  • Fix: Follow chained alias bindings when ref-counting used bindings in property collection.
  • Fix: Fix @ViewModelAssistedFactoryKey KClass key type to use out ViewModel instead.

Special thanks to @ansman and @jisungbin for contributing to this release!

What's Changed

New Contributors

Full Changelog: 0.8.0...0.8.1

0.8.0

01 Dec 20:15

Choose a tag to compare

  • New: New dev.zacsweers.metro:metrox-android artifact for Android AppComponentFactory support. See the docs for more information.

  • New: New dev.zacsweers.metro:metrox-viewmodel and metrox-viewmodel-compose artifacts for AndroidX ViewModel support. See the docs (compose docs ) for more information.

    • Should I use this?

      • Well, that's up to you! This artifact is mostly for projects coming from heavy use of more vanilla Android architecture components or hiltViewModel() use. Modern Android apps should use higher level architectures like Circuit* (Disclosure: I am one of the authors of Circuit, and I'm a big fan of it!), Voyager, etc. that abstract away ViewModel management.
  • New: Add generateMetroGraphMetadata Gradle task that writes a merged JSON dump of all binding graphs in the project. This can be chained from the GenerateGraphMetadataTask for further processing.

  • New: Add analyzeMetroGraph Gradle task that performs comprehensive graph analysis including fan-in/fan-out, betweenness centrality, dominator analysis, and longest path detection.

  • New: Add generateMetroGraphHtml Gradle task that generates interactive HTML visualizations of dependency graphs using ECharts. Features include force/circular layouts, filtering by package/scope/synthetic bindings, metrics heatmaps, and longest path highlighting. See the graph analysis docs for more information.

  • New: Add MetroArtifacts Gradle API for accessing Metro reports and graph metadata directories.

  • New: Add supportedHintContributionPlatforms Gradle DSL property to manually override supported hint contribution generation on different platforms. By default this computes default supported platforms based on the platform and Kotlin tooling version.

  • API Change: Rename generateJvmContributionHintsInFir Gradle DSL property to generateContributionHintsInFir. Note this property/mode still doesn't really work and is highly experimental at the moment.

  • Behavior Change: Add @DelicateMetroGradleApi annotations to relevant Gradle extension APIs.

  • Behavior Change: The generateContributionHints property now computes defaults per platform and per Kotlin compilation as a convention and can be overridden.

  • Behavior Change: All non-final classes with member injections or that extend classes with member injections must now be annotated with @HasMemberInjections. This is enforced with a new diagnostic check.

  • Enhancement: Lazily validate multibindings. Previously, multibindings were validated eagerly even if they were unused in a graph.

  • Enhancement: Report all duplicate bindings errors during graph construction rather than failing at first.

  • Enhancement: Support FirFunctionCall evaluation in annotation arguments during FIR.

  • Enhancement: Order before the Compose compiler on Kotlin 2.3.0+.

  • Enhancement: Only print Metro Gradle version configuration mismatch warnings once rather than per-compilation.

  • Enhancement: Report Metro Gradle configuration issues to Gradle's Problems API.

    • While this is nice for the IDE integration/Develocity integration, it's wholly hidden away from CLI users. So, Metro will still print these warnings to console too.
  • Fix: Support member injection of classes that have no member injections but do extend superclasses with member injections.

  • Fix: Catch more IrErrorType error types cases and report context/advice where possible.

  • Fix: Dedupe binding containers contributed to both parent and child graphs.

  • Fix: Fix support for Anvil's exclude argument in dependency graph annotations when Anvil interop is enabled.

  • Fix: Fix colliding reports destinations in KMP projects by disambiguating with the target path as another subdir indirection.

  • Fix: Fix qualifiers not being propagated to generated MembersInjector classes for multibindings.

  • Fix: Remove misleading "doesn't appear to be visible to this compilation" hint, as this hint was misreporting.

  • Fix: Fix not reserving properties multibinding contributors that are behind aliases.

  • Fix: Stub hint function bodies if FIR-generated.

  • Fix: Hide FIR-generated hint functions.

  • Fix: Full support injected Java fields from Dagger-processed Java supertypes.

  • Fix: Use correct type args for empty map provider return types.

  • Fix: Add Dagger's internal SetFactory, MapFactory and MapProviderFactory to known Dagger ClassIds in Provider interop.

  • Removed: Removed deprecated enableScopedInjectClassHints Gradle DSL property.

  • Removed: Removed deprecated enableStrictValidation Gradle DSL property.

  • Removed: Removed deprecated contributesGraphExtension Gradle DSL property.

  • Removed: Removed deprecated contributesGraphExtensionFactory Gradle DSL property.

  • Removed: Removed deprecated optionalDependencyBehavior Gradle DSL property.

  • Removed: Removed deprecated OptionalDependencyBehavior Gradle plugin class.

  • Removed: Removed deprecated includeAnvil Gradle DSL function.

  • Removed: Removed deprecated ContributesGraphExtension annotation.

  • Removed: Removed deprecated OptionalDependency annotation.

Special thanks to the following contributors for contributing to this release!

What's Changed

Read more

0.7.7

19 Nov 21:03

Choose a tag to compare

  • Add MetroCompilerPluginRegistrar.pluginId for forward compatibility with Kotlin 2.3.0's new API.

What's Changed

  • fix(deps): update okhttp monorepo to v5.3.2 by @renovate[bot] in #1382
  • chore(deps): update plugin spotless to v8.1.0 by @renovate[bot] in #1384
  • fix(deps): update dependency androidx.compose.material:material-navigation to v1.9.5 by @renovate[bot] in #1385
  • Test Kotlin 2.3.0-RC by @ZacSweers in #1383

Full Changelog: 0.7.6...0.7.7

0.7.6

17 Nov 23:36

Choose a tag to compare

  • Fix: Record IC lookups for merged supertypes to graph extensions.
  • Fix: Optimize checkScope() diagnostics in errors by checking if roots are empty first.
  • Fix: Fix diagnostic when an @Multibinds-annotated Map uses an enum as a key.
  • Fix: Fix Dagger interop error messages when validating @Modules with constructor-injected fields to match errors for @BindingContainers.
  • Fix: Catch IrErrorType error types earlier when generating missing binding hints.
  • Fix: Fix IC edge case when restoring a deleted contributed binding container.
  • Update shaded Okio to 3.16.3.
  • Build against Gradle 9.2.1.

Special thanks to @jonamireh, @neworld, and @JoelWilcox for contributing to this release!

What's Changed

  • fix(deps): update dependency com.google.googlejavaformat:google-java-format to v1.32.0 by @renovate[bot] in #1340
  • chore(deps): update plugin mavenpublish to v0.35.0 by @renovate[bot] in #1350
  • chore(deps): update plugin com.android.settings to v8.13.1 by @renovate[bot] in #1345
  • chore(deps): update dependency mkdocs-material to v9.7.0 by @renovate[bot] in #1347
  • chore(deps): update agp to v8.13.1 by @renovate[bot] in #1344
  • chore(deps): update dependency pymdown-extensions to v10.17 by @renovate[bot] in #1352
  • Add another test by @ZacSweers in #1351
  • Check if Multibinds map keys are enums by @jonamireh in #1354
  • chore(deps): update dependency pymdown-extensions to v10.17.1 by @renovate[bot] in #1357
  • chore(deps): update dependency mkdocs-macros-plugin to v1.5.0 by @renovate[bot] in #1363
  • Fix Dagger interop error messages when validating @Modules with constructor-injected fields to match errors for @BindingContainers by @JoelWilcox in #1367
  • Optimise checkScope diagnose, if roots are empty by @neworld in #1369
  • fix(deps): update okhttp monorepo to v5.3.1 by @renovate[bot] in #1374
  • chore(deps): update dependency click to v8.3.1 by @renovate[bot] in #1372
  • fix(deps): update okio to v3.16.3 by @renovate[bot] in #1371
  • Don't try to map error types in missing bindings hints by @ZacSweers in #1375
  • chore(deps): update gradle to v9.2.1 by @renovate[bot] in #1376
  • chore(deps): update actions/checkout digest to 93cb6ef by @renovate[bot] in #1377
  • Fix NoClassDefFoundError when changing scopes of a contributed interface by @jonamireh in #1356
  • fix(deps): update okio to v3.16.4 by @renovate[bot] in #1378
  • [IC] Fix restoring multibinding contribution not detected by @jonamireh in #1349

New Contributors

Full Changelog: 0.7.5...0.7.6

0.7.5

07 Nov 06:49

Choose a tag to compare

  • New: Add Guice interop. This is largely focused on Guice's Provider type, annotations, and existing interop with jakarta.inject annotations.
    metro {
      includeGuice()
    }
  • Enhancement: Improve IR caching layer with supertype caching.
  • Enhancement: Add diagnostic to check for Array properties in map key annotations that unwrap values.
  • Enhancement: Add diagnostic to check multibinds map keys are valid (primitives, strings, KClass, annotation classes, not arrays).
  • Enhancement: Improve multibinding star project checks.
  • Enhancement: Nudge @Binds functions toward private visibility like @Provides functions now that it's fully supported.
  • Fix: Don't treat l as an illegal char in name allocating. This was supposed to be ;.
  • Fix: Ensure all reserved properties by child graphs get properties in parents. Previously, there were some cases for bindings that were unused in the parent and otherwise did not meet the criteria for having a backing property would get missed in binding property collection.
  • Fix: Fix compiler crash when injecting a target type with star generics.
  • Fix: Fix ClassCastException when accessing a Provider contributed from a dagger.Module.
  • Split javax and jakarta interop APIs into separate artifacts from dagger for reuse.

Special thanks to @jonamireh for contributing to this release!

What's Changed

Full Changelog: 0.7.4...0.7.5

0.7.4

04 Nov 18:19

Choose a tag to compare

  • Fix: Support more than 32 parameters to Graph factories.
  • Fix: Support more than 32 accessors in Graphs.
  • Fix: Transform INSTANCE access types for GraphDependency bindings.
  • Fix: Fix ordering of setter member injection parameters when reading injectors across modules.
  • [change] When generating reports, create directory structures matching packages rather than generating all to one top-level dir.

Special thanks to @jonamireh, @kevinguitar, and @JoelWilcox for contributing to this release!

What's Changed

  • Encode factory package name in report directory instead of report file name to reduce likelihood of 'file name too long' exceptions by @JoelWilcox in #1304
  • chore(deps): update dependency markdown to v3.10 by @renovate[bot] in #1316
  • ClassCastException when injecting an Optional from a nested GraphExtension by @jonamireh in #1312
  • Failing test for member injecting a parent's abstract val by @kevinguitar in #1313
  • Expand bitfield support by @ZacSweers in #1319
  • fix(deps): update ksp monorepo to v2.3.1 by @renovate[bot] in #1317

Full Changelog: 0.7.3...0.7.4

0.7.3

02 Nov 04:28

Choose a tag to compare

  • New: Support interop with Dagger/Anvil-generated member injector classes.
  • Enhancement: Skip reading members when loading externally compiled member injector classes. Parameters are now computed from their static inject* functions.
  • Enhancement: Improve logic for avoiding reserved keywords or illegal character for names in more platforms.
  • Enhancement: Inline empty multibinding expressions in code gen.
  • Enhancement: Better detect static-ish functions in generated Kotlin factories from Dagger/Anvil interop.
  • Enhancement: Cache members injector binding lookups.
  • Enhancement: Don't double-lookup members injectors already computed from roots.
  • Enhancement: Support Kotlin 2.3.0-Beta2.
  • Enhancement: Test against Kotlin 2.2.21.
  • Enhancement: Improve generated graph impl declaration checks.
  • Fix: Work around "LookupSymbols are not yet converted to ProgramSymbols" issue (KT-80412) in incremental compilation by avoiding using $$ prefixes in generated class names.
  • Fix: Fix interop support for two layers of Provider interop in map multibindings (i.e. Provider<Map<Key, Provider<Value>>).
  • Deprecate includeAnvil() Gradle DSL function in favor of more specific includeAnvilForDagger() and includeAnvilForKotlinInject() functions.
  • Move interop annotations controls to compiler. For Gradle users, there's mostly no change (other than the above). For users of any other build system, this makes it a bit easier to reuse the interop annotations logic.
  • [docs] Add compatibility docs: https://zacsweers.github.io/metro/latest/compatibility/. Metro supports a moving range of Kotlin versions, this page captures the tested versions for each release.
  • [docs] Add stability docs: https://zacsweers.github.io/metro/latest/stability/

Special thanks to @jonamireh, @hossain-khan, and @l2hyunwoo for contributing to this release!

What's Changed

  • fix(deps): update dependency com.autonomousapps:gradle-testkit-support to v0.21 by @renovate[bot] in #1258
  • fix(deps): update dependency androidx.work:work-runtime to v2.11.0 by @renovate[bot] in #1268
  • fix(deps): update dependency androidx.compose.material:material-navigation to v1.9.4 by @renovate[bot] in #1267
  • fix(deps): update ksp monorepo to v2.3.0 by @renovate[bot] in #1259
  • fix(deps): update kct to v0.11.0 by @renovate[bot] in #1270
  • fix(deps): update dependency com.autonomousapps:gradle-testkit-support to v0.22 by @renovate[bot] in #1273
  • Fix Dagger-generated MemberInjector invocation by @jonamireh in #1269
  • chore: remove reference to non-existent samples/multi-module-test by @hossain-khan in #1274
  • feat: Add reserved keywords from other platforms & add it to validation logic by @l2hyunwoo in #1271
  • Update compat docs with releases by @ZacSweers in #1275
  • Use new jvm-default flag by @ZacSweers in #1276
  • Rename function by @ZacSweers in #1278
  • Refactor multibinding code gen + inline empty expressions by @ZacSweers in #1279
  • chore(deps): update actions/upload-artifact action to v5 by @renovate[bot] in #1280
  • Refactor more things to graph subpackage by @ZacSweers in #1281
  • Use gitattr for normalizing by @ZacSweers in #1283
  • Implement static-ish by @ZacSweers in #1282
  • Fix: Qualifiers ignored for member-injected Java classes with interop by @jonamireh in #1285
  • chore(deps): update dependency mkdocs-macros-plugin to v1.4.1 by @renovate[bot] in #1286
  • chore(deps): update dependency termcolor to v3.2.0 by @renovate[bot] in #1289
  • Move interop logic from gradle plugin to plugin by @ZacSweers in #1288
  • Add stability docs plus some other notes by @ZacSweers in #1290
  • fix(deps): update dependency com.google.googlejavaformat:google-java-format to v1.31.0 by @renovate[bot] in #1291
  • Fix gradle plugin wiring by @ZacSweers in #1292
  • Sort out metadata writing logic a bit by @ZacSweers in #1293
  • [Redo] Qualified member-injected fields in Java cause a MissingBinding error by @jonamireh in #1294
  • Kotlin 2.3.0-Beta2 by @ZacSweers in #1295
  • fix(deps): update compose.jb to v1.9.2 by @renovate[bot] in #1298
  • chore(deps): update gradle to v9.2.0 by @renovate[bot] in #1299
  • fix(deps): update junit-framework monorepo to v6.0.1 by @renovate[bot] in #1306
  • fix(deps): update okhttp monorepo to v5.3.0 by @renovate[bot] in #1302
  • chore(deps): update dependency mkdocs-material to v9.6.23 by @renovate[bot] in #1307
  • Avoid $$ prefixes in class names to avoid KT-80412 by @jonamireh in #1297
  • chore(deps): update plugin buildconfig to v5.7.1 by @renovate[bot] in #1308
  • Finish fixing double-provider interop with MapProviderFactory by @ZacSweers in #1296
  • Fix another jvm-default by @ZacSweers in #1310
  • Abstract the graph factory in sample by @ZacSweers in #1309

New Contributors

Full Changelog: 0.7.2...0.7.3

0.7.2

22 Oct 06:32

Choose a tag to compare

  • Fix: Fix eager initialization of some bindings going into multibindings.
  • Fix: Fix injection of Lazy-wrapped multibindings.

What's Changed

Full Changelog: 0.7.1...0.7.2

0.7.1

21 Oct 20:13

Choose a tag to compare

🚨 This release has a severe bug in multibinding code gen, please use 0.7.2 instead!

  • New: Add missing dependency hints for missing bindings errors

    [Metro/MissingBinding] Cannot find an @Inject constructor or @Provides-annotated function/property for: FooImpl
    
        FooImpl is injected at
            [AppGraph] Bindings.bind: FooImpl
        Base is requested at
            [AppGraph] AppGraph.base
    
    (Hint)
    'FooImpl' doesn't appear to be visible to this compilation. This can happen when a binding references a type from an 'implementation' dependency that isn't exposed to the consuming graph's module.
    Possible fixes:
    - Mark the module containing 'FooImpl' as an 'api' dependency in the module that defines 'Bindings' (which is requesting it).
    - Add the module containing 'FooImpl' as an explicit dependency to the module that defines 'AppGraph'.
    
  • Enhancement: Improve code generation around multibinding collection builders and contributors, using more lazy getters in graph code gen.

  • Enhancement: Short-circuit empty map providers to emptyMap().

  • Enhancement: Support default values for assisted parameter arguments in top-level function injection.

  • Enhancement: Allow using @Contributes* annotations on assisted factories with contributesAsInject enabled.

  • Enhancement: Allow @OptionalBinding annotation to be customizable/replaceable.

  • Change: Deprecate @OptionalDependency in favor of @OptionalBinding. Same behavior, just a slightly more consistent name.

  • Fix: Compute Optional instance lazily when requested as a Provider<Optional<T>> and the underlying optional is not empty. Only applies to @BindsOptionalOf interop.

  • Fix: Don't generate duplicate init() functions when chunking initializers if graphs already have an explicit init() function.

  • Fix: Fix support for assisted inject with no assisted params.

  • Fix: Detect platform types in just the kotlin package. Previously it missed any that didn't have multiple package segments.

  • Fix: Align unused context parameter special names on Kotlin 2.3.x.

  • Remove 2.3.0-dev-7984 compat (superseded by 2.3.0-Beta1).

Special thanks to @Lavmee, @kevinguitar, and @jackwilsdon for contributing to this release!

What's Changed

New Contributors

Full Changelog: 0.7.0...0.7.1