Releases: ZacSweers/metro
0.8.2
- 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.testtransitive dependency inmetrox-viewmodel-composeartifact.
What's Changed
- Fix test dep by @ZacSweers in #1472
- Avoid removeFirst() by @ZacSweers in #1473
Full Changelog: 0.8.1...0.8.2
0.8.1
- New: Experimental support for Kotlin
2.3.20dev builds. See the compatibility docs for tested versions. - Fix: Follow chained alias bindings when ref-counting used bindings in property collection.
- Fix: Fix
@ViewModelAssistedFactoryKeyKClass key type to useout ViewModelinstead.
Special thanks to @ansman and @jisungbin for contributing to this release!
What's Changed
- 2.3.20 compat by @ZacSweers in #1445
- Add regression tests for providing multibindings directly by @ZacSweers in #1459
- Add missing syntax highlighting by @jisungbin in #1461
- Update actions/checkout digest to 8e8c483 by @renovate[bot] in #1463
- Follow aliases for refcounting too by @ZacSweers in #1464
- Add 2.3.0-RC2 to testing by @ZacSweers in #1465
- Pass the extras when creating view models by @ansman in #1466
- Update dependency androidx.activity:activity-compose to v1.12.1 by @renovate[bot] in #1467
- Fix an issue with the VM docs by @ansman in #1468
- Fix ViewModelAssistedFactoryKey target + add tests by @ZacSweers in #1469
- Update to nav3 for sample by @ZacSweers in #1470
New Contributors
Full Changelog: 0.8.0...0.8.1
0.8.0
-
New: New
dev.zacsweers.metro:metrox-androidartifact for AndroidAppComponentFactorysupport. See the docs for more information. -
New: New
dev.zacsweers.metro:metrox-viewmodelandmetrox-viewmodel-composeartifacts for AndroidXViewModelsupport. 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 awayViewModelmanagement.
- Well, that's up to you! This artifact is mostly for projects coming from heavy use of more vanilla Android architecture components or
-
-
New: Add
generateMetroGraphMetadataGradle task that writes a merged JSON dump of all binding graphs in the project. This can be chained from theGenerateGraphMetadataTaskfor further processing. -
New: Add
analyzeMetroGraphGradle task that performs comprehensive graph analysis including fan-in/fan-out, betweenness centrality, dominator analysis, and longest path detection. -
New: Add
generateMetroGraphHtmlGradle 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
MetroArtifactsGradle API for accessing Metro reports and graph metadata directories. -
New: Add
supportedHintContributionPlatformsGradle 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
generateJvmContributionHintsInFirGradle DSL property togenerateContributionHintsInFir. Note this property/mode still doesn't really work and is highly experimental at the moment. -
Behavior Change: Add
@DelicateMetroGradleApiannotations to relevant Gradle extension APIs. -
Behavior Change: The
generateContributionHintsproperty now computes defaults per platform and per Kotlin compilation as aconventionand 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
FirFunctionCallevaluation 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
ProblemsAPI.- 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
IrErrorTypeerror 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
excludeargument 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
MembersInjectorclasses 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,MapFactoryandMapProviderFactoryto known Dagger ClassIds inProviderinterop. -
Removed: Removed deprecated
enableScopedInjectClassHintsGradle DSL property. -
Removed: Removed deprecated
enableStrictValidationGradle DSL property. -
Removed: Removed deprecated
contributesGraphExtensionGradle DSL property. -
Removed: Removed deprecated
contributesGraphExtensionFactoryGradle DSL property. -
Removed: Removed deprecated
optionalDependencyBehaviorGradle DSL property. -
Removed: Removed deprecated
OptionalDependencyBehaviorGradle plugin class. -
Removed: Removed deprecated
includeAnvilGradle DSL function. -
Removed: Removed deprecated
ContributesGraphExtensionannotation. -
Removed: Removed deprecated
OptionalDependencyannotation.
Special thanks to the following contributors for contributing to this release!
What's Changed
- fix(deps): update poko to v0.20.2 by @renovate[bot] in #1390
- chore(deps): update plugin buildconfig to v6 by @renovate[bot] in #1391
- fix(deps): update dependency androidx.activity:activity-compose to v1.12.0 by @renovate[bot] in #1388
- fix(deps): update androidx.lifecycle to v2.10.0 by @renovate[bot] in #1387
- Catch more error type cases by @ZacSweers in #1392
- fix(deps): update ksp monorepo to v2.3.3 by @renovate[bot] in #1395
- Gradle task for generating a manifest of Metro graph metadata by @bjdodson in #1370
- Remove extra line in injection-types.md by @zsmb13 in #1398
- chore(deps): update actions/checkout action to v6 by @renovate[bot] in #1394
- fix(deps): update anvil to v0.5.0 by @renovate[bot] in #1402
- chore(deps): update plugin buildconfig to v6.0.3 by @renovate[bot] in #1399
- Dedupe inherited containers + refactor multibound transforms by @ZacSweers in #1405
- Move ContributesTo site checks over by @ZacSweers in #1406
- Update report message by @ZacSweers in #1407
- chore(deps): update plugin buildconfig to v6.0.5 by @renovate[bot] in #1408
- Lazily validate multibindings by @ZacSweers in #1412
- Don't fail on sonatype 429s for now by @ZacSweers in #1414
- README spruce-up by @ZacSweers in #1415
- Pass + cache host classpaths in KspAdditionalSourceProvider by @ZacSweers in #1413
- chore(deps): update mikepenz/action-junit-report action to v6 by @renovate[bot] in #1416
- Support Anvil's exclude argument by @jonamireh in #1410
- Added functional test for report-writing failures with new AGP by @jonapoul in #1400
- Fix missing qualifiers on multibinding member injections by @kevinguitar in #1389
- Introduce metrox-android by @yschimke in #806
- Added a sample project for multi-module ViewModel injection by @jonapoul in #886
- Remove misleading hint by @ZacSweers in #1417
- fix(deps): update dependency org.jetbrains.androidx.navigation:navigation-compose to v2.9.1 by @renovate[bot] in #1418
- Fix path chaining for windows by @ZacSweers in #1419
- Misc cleanup by @ZacSweers in #1420
- fix(deps): update ktor monorepo to v3.3.3 by @renovate[bot] in #1423
- chore(deps): update dependency pymdown-extensions to v10.17.2 by @renovate[bot] in #1424
- Fix multiplatform windows tests by @ZacSweers in #1425
- Ignore warning by @ZacSweers in #1429
- Support evaluatable FIR expressions in FIR annotations by @ZacSweers in #1430
- Add new graph analysis tools by @ZacSweers in #1428
- Introduce metrox-viewmodel artifacts by @ZacSweers in #1426
- Don't inline aliases to other types to multibindings by @ZacSweers in #1432
- fix(deps): update dependency org.jetbrains.androidx.lifecycle:lifecycle-viewmodel to v2.9.6 by @renovate[bot] in #1433
- fix(deps): update dependency org.jetbrains.andro...
0.7.7
- Add
MetroCompilerPluginRegistrar.pluginIdfor forward compatibility with Kotlin2.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
- 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
IrErrorTypeerror 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
- New: Add Guice interop. This is largely focused on Guice's
Providertype, annotations, and existing interop with jakarta.inject annotations.metro { includeGuice() } - Enhancement: Improve IR caching layer with supertype caching.
- Enhancement: Add diagnostic to check for
Arrayproperties 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
@Bindsfunctions towardprivatevisibility like@Providesfunctions now that it's fully supported. - Fix: Don't treat
las 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
ClassCastExceptionwhen accessing aProvidercontributed from adagger.Module. - Split
javaxandjakartainterop APIs into separate artifacts from dagger for reuse.
Special thanks to @jonamireh for contributing to this release!
What's Changed
- Fix order check of toSafeIdentifier by @ZacSweers in #1322
- Refactor provider symbol handling by @ZacSweers in #1324
- Fix ClassCastException when accessing a Provider contributed from a dagger.Module by @jonamireh in #1321
- fix(deps): update ktor monorepo to v3.3.2 by @renovate[bot] in #1328
- fix(deps): update dependency androidx.navigation:navigation-compose to v2.9.6 by @renovate[bot] in #1330
- Update to AGP 8.13.0 by @ZacSweers in #1136
- Refactor type conversion + add guice interop by @ZacSweers in #1333
- Add the design doc by @ZacSweers in #1336
- Guice module interop + IrCache by @ZacSweers in #1335
- fix(deps): update ksp monorepo to v2.3.2 by @renovate[bot] in #1337
- fix(deps): update compose.jb to v1.9.3 by @renovate[bot] in #1334
- Ensure parent-unused, unscoped properties are reserved if child graphs expect by @jonamireh in #1332
- Fix crash on star injections by @ZacSweers in #1338
- Misc improvements to multibinding diagnostics by @ZacSweers in #1339
Full Changelog: 0.7.4...0.7.5
0.7.4
- Fix: Support more than 32 parameters to Graph factories.
- Fix: Support more than 32 accessors in Graphs.
- Fix: Transform
INSTANCEaccess types forGraphDependencybindings. - 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
- 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
Providerinterop in map multibindings (i.e.Provider<Map<Key, Provider<Value>>). - Deprecate
includeAnvil()Gradle DSL function in favor of more specificincludeAnvilForDagger()andincludeAnvilForKotlinInject()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
- @jonamireh made their first contribution in #1269
- @l2hyunwoo made their first contribution in #1271
Full Changelog: 0.7.2...0.7.3
0.7.2
- Fix: Fix eager initialization of some bindings going into multibindings.
- Fix: Fix injection of
Lazy-wrapped multibindings.
What's Changed
- chore(deps): update plugin testkit to v0.17 by @renovate[bot] in #1256
- Fix handling of lazy multis by @ZacSweers in #1261
- Fix eager initialization of some bindings going into multibindings. by @ZacSweers in #1263
Full Changelog: 0.7.1...0.7.2
0.7.1
🚨 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 withcontributesAsInjectenabled. -
Enhancement: Allow
@OptionalBindingannotation to be customizable/replaceable. -
Change: Deprecate
@OptionalDependencyin favor of@OptionalBinding. Same behavior, just a slightly more consistent name. -
Fix: Compute
Optionalinstance lazily when requested as aProvider<Optional<T>>and the underlying optional is not empty. Only applies to@BindsOptionalOfinterop. -
Fix: Don't generate duplicate
init()functions when chunking initializers if graphs already have an explicitinit()function. -
Fix: Fix support for assisted inject with no assisted params.
-
Fix: Detect platform types in just the
kotlinpackage. 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-7984compat (superseded by2.3.0-Beta1).
Special thanks to @Lavmee, @kevinguitar, and @jackwilsdon for contributing to this release!
What's Changed
- Generate properties for bindings by @ZacSweers in #1221
- Fix mike handling of snapshots by @ZacSweers in #1224
- Ensure safe setDelegate() call order by @ZacSweers in #1223
- Make Optionals lazier by @ZacSweers in #1227
- Use emptyMap() for empty map instance multis by @ZacSweers in #1228
- Use MapBuilder for simple scalar maps by @ZacSweers in #1230
- Fix spotless config by @ZacSweers in #1231
- Support default values for assisted params in function injection by @ZacSweers in #1226
- Fix assisted injection non-matching key error by @jackwilsdon in #1234
- Fix assisted inject with no assisted params by @ZacSweers in #1237
- Remove setDelegate ordering by @ZacSweers in #1238
- Add better hints for missing dependencies by @ZacSweers in #1239
- Fix double-wrapping of map provider values by @ZacSweers in #1245
- Fix test compiler version setup on CI by @ZacSweers in #1178
- Allow using @ContributesBinding on assisted factories with
contributesAsInjectenabled by @kevinguitar in #1240 - Add a fallback to testCompilerVersionProvider by @kevinguitar in #1247
- feat: wip support for kotlin 2.3.20-dev-670. by @Lavmee in #1218
- Rename OptionalDependency to OptionalBinding by @ZacSweers in #1252
New Contributors
- @jackwilsdon made their first contribution in #1234
- @Lavmee made their first contribution in #1218
Full Changelog: 0.7.0...0.7.1