anvil

A Kotlin compiler plugin to make dependency injection with Dagger 2 easier.

APACHE-2.0 License

Stars
1.3K

Bot releases are visible (Hide)

anvil - v2.5.0-beta05 Latest Release

Published by github-actions[bot] 6 months ago

Added

  • Support KSP in BindsMethodValidator by @IlyaGulya (#831)

Fixed

  • fix interface based @ContributesSubcomponent.Factory in KSP by @gabrielittner (#931)
  • Fix KSP resolution of Priority (#933)
  • Gracefully handle module name resolution in KSP (#947)
  • Always generate provider factories for binding modules (#951)
  • use the resolved value of const arguments in propagated annotation arguments (#940)
  • re-run analysis between an incremental sync and code generation (#943)
  • delay @ContributesSubcomponent generation until the last analysis rounds (#946)

Dependencies

  • Update dependency gradle to v8.7 (#937)
  • Update dagger to v2.51.1 (#944)
anvil - v2.5.0-beta04

Published by github-actions[bot] 7 months ago

Changed

  • Interface merging is now done in the IR backend, improving performance and future compatibility with K2.
  • Update Dagger to 2.51.
  • @ContributesBinding and @ContributesMultibinding have been completely reworked to a new implementation that generates one binding dagger module for each contributed binding. While not an ABI-breaking change, this does change the generated code and requires users to re-run Anvil's code gen over any projects contributing bindings in order to be merged with the new implementation.

Fixed

  • Code generated because of a @Contributes___ annotation in a dependency module is now correctly deleted when there is a relevant change in the dependency module.
  • Nested interfaces and modules can now be contributed to enclosing classes.
anvil - v2.5.0-beta03

Published by github-actions[bot] 8 months ago

Fixed

  • Don't fail the build when a @Binds-annotated function binds a generic type (#885)
    • This is a revert of the changes in (#833).
anvil - v2.5.0-beta02

Published by github-actions[bot] 8 months ago

Fixed

  • Binding supertype which is narrower than return type is wrongly allowed by @IlyaGulya in (#833)
  • Don't cache the projectDir or binaryFile as part of GeneratedFileCache by @RBusarow in (#883)
  • Add restored-from-cache, previously-generated files to analysis results after code generation by @RBusarow in (#882)

Other Notes & Contributions

  • @IlyaGulya made their first contribution in (#833)
anvil - v2.5.0-beta01

Published by github-actions[bot] 8 months ago

Added

  • Incremental compilation and build caching fixes (#836)
    This feature is disabled by default.
    It can be enabled via a Gradle property or the Gradle DSL:

    Gradle Properties

    # default is false
    com.squareup.anvil.trackSourceFiles=true
    

    Gradle DSL

    // build.gradle[.kts]
    anvil {
      trackSourceFiles = true // default is false
    }
    
  • Configuration options can now be set via Gradle properties (#851)

    # ./gradle.properties
    com.squareup.anvil.addOptionalAnnotations=true
    com.squareup.anvil.disableComponentMerging=true
    com.squareup.anvil.generateDaggerFactories=true
    com.squareup.anvil.generateDaggerFactoriesOnly=true
    com.squareup.anvil.syncGeneratedSources=true
    com.squareup.anvil.trackSourceFiles=true
    

Changed

  • Upgrade Kotlin to 1.9.22 (#814)
  • don't leak Anvil's annotation artifacts to the target project's compile classpath (#822)
  • Update to dagger 2.50 (#830)

Removed

  • Drop Kotlin 1.8 support (#841)

Custom Code Generator

  • The GeneratedFile result type has been deprecated in favor of GeneratedFileWithSources. This new type allows for precise tracking of the generated files, which in turn drastically improves incremental compilation performance (#693).

Other Notes & Contributions

  • Support KSP in ContributesSubcomponentGenerator (#828)
anvil - v2.4.9

Published by github-actions[bot] 10 months ago

Changed

  • Upgrade Kotlin to 1.9.20

Fixed

  • Fix a configuration error related to version catalogs when building on Windows (#744)

Other Notes & Contributions

  • Use Anvil version 2.4.9-1-8 if your project is using Kotlin 1.8.x. This is also the last planned release with Kotlin 1.8.x support.
anvil - v2.4.8

Published by github-actions[bot] about 1 year ago

Added

  • Anvil now provides an annotations-optional artifact for non-required annotations that we've found to be helpful with managing larger dependency graphs, including @SingleIn and @ForScope (#692).

Fixed

  • Support explicit API mode for complex map keys (#735).
  • Fix a bug where conflicting imports could be generated (#738).
  • Fix suspend lambda parameters not being supported (#745).

Other Notes & Contributions

  • Thanks to @gabrielittner and @bddckr for contributing to this release.
  • Use Anvil version 2.4.8-1-8 if your project is using Kotlin 1.8.x.
anvil - v2.4.7

Published by github-actions[bot] about 1 year ago

Changed

  • Upgrade to Kotlin 1.9.0 as the primary supported version
  • Upgrade to Kotlin 1.8.22 for dual-release artifacts. Use Anvil version 2.4.7-1-8 if your project is using Kotlin 1.8.x.
  • Upgrade to Dagger 2.46.1
  • Upgrade to kotlinx-metadata 0.6.2
anvil - v2.4.6

Published by github-actions[bot] over 1 year ago

Changed

  • Upgrade KotlinPoet to 1.13.0 and fix bug uncovered by new TypeName#equals/hashCode changes, see #699.
  • Upgrade Kotlin to 1.8.21.
anvil - v2.4.5

Published by github-actions[bot] over 1 year ago

Changed

  • Raise minimum Kotlin version to 1.8.20.
  • Raise minimum AGP version to 7.1.0.
  • The Kotlin Gradle Plugin (both the core plugin and the API artifact) are no longer a dependency of the Anvil Gradle Plugin. Instead, it's now a compileOnly dependency, allowing the plugin to defer to whatever version the user already has. If you were accidentally depending on KGP through Anvil, you'll need to explicitly add the plugin yourself now.

Removed

  • Support for the old compiler backend. The Java stub generating task uses the new backend by default since Kotlin 1.8.20.

Fixed

  • Fix duplicate generated binding method names. If a class contributes multiple bindings and the bound types have the same short name, then Anvil would generate methods with duplicate names that clash in the end.
  • Support Any as bound type when using @ContributesBinding or @ContributesMultibinding, see #680.

Custom Code Generator

  • Add option to change the JVM target when testing code generators with the custom AnvilCompilation class, see #682.
anvil - v2.4.4

Published by github-actions[bot] almost 2 years ago

Added

  • Added support for Kotlin 1.8.

Changed

  • The issue that required disabling precise Java tracking is not needed anymore. The workaround has been removed.

Removed

  • Remove support for Kotlin 1.7. Anvil only supports Kotlin 1.8 moving forward.

Custom Code Generator

  • Add ability to query top-level functions and properties. The entry point is projectFiles.topLevelFunctionReferences(module) and projectFiles.topLevelPropertyReferences(module). This allows you write code generators reacting to top-level functions and properties and not only classes, see #644.
  • The FunctionReference type has been renamed to MemberFunctionReference and a new super type FunctionReference has been introduced for TopLevelFunctionReference and MemberFunctionReference.
  • The PropertyReference type has been renamed to MemberPropertyReference and a new super type PropertyReference has been introduced for TopLevelPropertyReference and MemberPropertyReference.
anvil - v2.4.3

Published by github-actions[bot] almost 2 years ago

Added

  • Add support for generating MapKeyCreator classes when generating Dagger factories, see #651.
  • @Binds methods are now validated for correctness when generating Dagger factories, see #649.

Changed

  • Upgrade Kotlin to 1.7.20 and Gradle to 7.5.1, see #643.
  • For Kotlin 1.8.x releases, we now use a fork of kotlin-compile-testing: dev.zacsweers.kctfork:core:0.1.0-1.8.0-Beta01.
  • Use Anvil version 2.4.3-1-8-0-RC if you want to test Kotlin 1.8.0-RC. Until Anvil has fully adopted Kotlin 1.8 we'll publish additional versions that are required due to compiler API incompatibilities.

Fixed

  • Fix resolving types whose packages are wrapped in backticks, see #665.
  • Fix resolving types when paired with qualifiers, see #664.
  • Fix inconsistency between Dagger and Anvil for generated factory names involving a dash-separated module name, see #653.
  • Fix resolving types whose names are wrapped in backticks, see #641.
  • Update outdated documentation on incremental compilation limitations, see #637.
anvil - v2.4.2

Published by github-actions[bot] about 2 years ago

Removed

  • Remove support for Kotlin 1.6. Anvil only supports Kotlin 1.7 moving forward.

Fixed

  • Upgraded KotlinPoet to the latest version to fix potential conflicts with other libraries, see #613.
  • When resolving FqNames check the inner class hierarchy for the right reference, see #617.
  • An imported top level function should not be considered a class.
  • Support star projections for wrapped type references, see #620.
  • Support contributing types with Any as boundType, see #619.
  • Improve the error message for contributed inner classes, see #616.
  • Don't share the output directory for the DisableIncrementalCompilationTask, if there are multiple Kotlin compilation tasks for the same module, see #602.
  • Unwrap types from type aliases for TypeReference, see #611.
  • Remove incremental compilation workaround, see #627.
  • Fix annotation arguments using string templates not being parsed correctly, see #631.
  • Align Anvil with Dagger and don't support member injection for private fields, see #341.
anvil - v2.4.1

Published by github-actions[bot] over 2 years ago

Changed

  • Attention: This version supports Kotlin 1.7.0 only. For Kotlin 1.6.* support please use version 2.4.1-1-6 instead. Future Anvil versions will remove support for Kotlin 1.6.

Fixed

  • Support wildcard imports for constants when resolving annotation arguments, see #592.
  • Fix dagger factory member injection not handling generics, see #486.
  • Correctly merge bindings from all scopes, if multiple @Merge* annotations are used, see #596.

Custom Code Generator

  • Change the method to get all super classes for ClassReference to return TypeReference instead.
  • Avoid a stackoverflow when querying all super types, see #587.
  • Create PropertyReference.Psi from primary constructor properties to have the same behavior as the descriptor implementation, see #609.
anvil - v2.4.0

Published by github-actions[bot] over 2 years ago

Added

  • Anvil annotations are repeatable. Modules and bindings can now be contributed multiple times to different scopes. Multiple scopes can be merged in a single component, see #236.
  • Rewrote many of the internals of Anvil and as a result Anvil is up to 41% faster due to heavy caching of already parsed code structures.
  • Automatically publish snapshots for the main branch.
  • Documented Anvil's internal, see here.

Changed

  • Many of the internals of Anvil were rewritten and the non-stable APIs of the compiler-utils artifact have changed. Some highlights:
    • Instead of working with PSI or Descriptor APIs directly, you should work with the common ClassReference API.
    • ClassReference is a sealed class and either implemented with PSI or Descriptors, so it's easy to fallback to a specific API and add your own extensions.
    • The entry point to iterate through all classes used be classesAndInnerClass(module), use classAndInnerClassReferences() instead.

Removed

  • Removed support for Kotlin 1.5.
  • Removed deprecated APIs from the AnvilExtension in the gradle plugin.

Fixed

  • Filter duplicate generated properties, see #565.
  • Generate code for @ContributedSubcomponent when the trigger is created AFTER the contribution, see #478.
  • Properly parse the FqName if the type reference is an inner class, see #479.
anvil - v2.4.0-M2

Published by github-actions[bot] over 2 years ago

Added

  • Made annotations repeatable. Modules and bindings can now be contributed multiple times to different scopes. Multiple scopes can be merged in a single component.

Fixed

  • Filter duplicate generated properties, see #565.
anvil - v2.4.0-M1

Published by github-actions[bot] over 2 years ago

Added

  • Rewrote many of the internals of Anvil and as a result Anvil is up to 41% faster.
  • Automatically publish snapshots for the main branch.
  • Documented Anvil's internal, see here.

Removed

  • Removed support for Kotlin 1.5.
  • Removed deprecated APIs from the AnvilExtension in the gradle plugin.

Fixed

  • Generate code for @ContributedSubcomponents when the trigger is created AFTER the contribution, see #478.
  • Properly parse the FqName if the type reference is an inner class, see #479.
anvil - v2.3.11

Published by vRallev over 2 years ago

  • Promote @ContributesSubcomponent to stable, see #474.
  • Support replacing @ContributesSubcomponent through a new replaces attribute, see #466.
  • Avoid duplicate bindings when a @ContributesSubcomponent uses a factory and is used in multiple parent components, see #459.
  • Fix rare duplicate bindings error for the same type with incremental compilation, see #460.
  • Support member injection for super types from different modules, see #438, #439 and #442.
  • Support custom CodeGenerators for AnvilCompilation. This makes it easier to unit-test specific scenarios, see #470.
  • Detect duplicated generated files (helpful for custom CodeGenerators), see #467.
  • Fix the import resolver for wildcard imports and inner classes, see #468.
  • Use Anvil version 2.3.11-1-6-10 if you use Kotlin 1.6.10. Until Anvil hasn't adopted Kotlin 1.6 I'll publish additional versions that are required due to compiler API incompatibilities.
    • Attention: This is the last release to simultaneously support Kotlin 1.5 and 1.6. The next release will only support Kotlin 1.6.
anvil - v2.3.10

Published by vRallev almost 3 years ago

  • New experimental annotation @ContributesSubcomponent to delay merging contributions until the parent component is created, see #160.
  • Add option to contribute class using @MergeInterfaces and @MergeModules to another scope with @ContributesTo.
  • Add a workaround for a bug in the Kotlin 1.6.0 compiler, see KT-49340.
  • Use Anvil version 2.3.10-1-6-0 if you want to test Kotlin 1.6.0. Until Anvil hasn't adopted Kotlin 1.6 I'll publish additional versions that are required due to compiler API incompatibilities.
anvil - v2.3.9

Published by vRallev almost 3 years ago

  • Add a workaround for AGP to sync generated sources with syncGeneratedSources, see #413.
  • Ignore functions with defaults in assisted factories, see #415.
  • Use Anvil version 2.3.9-1-6-0-RC2 if you want to test Kotlin 1.6.0-RC2. Until Anvil hasn't adopted Kotlin 1.6 I'll publish additional versions that are required due to compiler API incompatibilities.
  • Use Anvil version 2.3.9-1-6-0 if you want to test Kotlin 1.6.0. Until Anvil hasn't adopted Kotlin 1.6 I'll publish additional versions that are required due to compiler API incompatibilities.
Package Rankings
Top 11.82% on Repo1.maven.org
Badges
Extracted from project README
Maven Central CI
Related Projects