diff --git a/README.md b/README.md index 17e4194c7..3fe4278e3 100644 --- a/README.md +++ b/README.md @@ -42,14 +42,14 @@ Setup ```groovy dependencies { // Include this in kotlin or android modules - implementation("se.ansman.dagger.auto:core:0.6.2") - kapt("se.ansman.dagger.auto:compiler:0.6.2") + implementation("se.ansman.dagger.auto:core:0.6.3") + kapt("se.ansman.dagger.auto:compiler:0.6.3") // Include this only in android modules - implementation("se.ansman.dagger.auto:android:0.6.2") + implementation("se.ansman.dagger.auto:android:0.6.3") // Add these if you want to replace objects during tests - testImplementation("se.ansman.dagger.auto:android-testing:0.6.2") - kaptTest("se.ansman.dagger.auto:compiler:0.6.2") + testImplementation("se.ansman.dagger.auto:android-testing:0.6.3") + kaptTest("se.ansman.dagger.auto:compiler:0.6.3") } ``` diff --git a/gradle.properties b/gradle.properties index c44045e32..9e490a89a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,5 +11,5 @@ kapt.include.compile.classpath=false android.useAndroidX=true -version=0.7.0-SNAPSHOT -latestRelease=0.6.2 +version=0.6.3 +latestRelease=0.6.3 diff --git a/src/doc/dokka/0.6.3/android/index.html b/src/doc/dokka/0.6.3/android/index.html new file mode 100644 index 000000000..20edda4c4 --- /dev/null +++ b/src/doc/dokka/0.6.3/android/index.html @@ -0,0 +1,86 @@ + + +
+ +An Initializer that will initialize a Singleton scoped AutoDaggerStartupInitializer.
This will be called by androidx.startup, provides no result and has no dependencies.
0.2
An Initializer that will initialize a Singleton scoped AutoDaggerStartupInitializer.
Denotes that the class referenced using type is to be replaced by this type.
The type to replace must be annotated with AutoBind. Any qualifiers and binding keys will be copied from the referenced type.
The annotated class must implement the types which are bound by the referenced type.
If the replaced type uses multibindings (AutoBindIntoSet or AutoBindIntoMap) then those are only replaced if the annotated type also implements them. Otherwise the multibinding is removed
So for example. If the target type uses @AutoBindIntoSet
to bind it as a Closeable
but your replacement doesn't implement Closeable
then that binding is removed. If it does implement Closeable
then the binding is replaced with the fake binding.
Normally the replacement object needs to be provided to the dependency graph using either an @Provides
annotated method or using an @Inject
annotated constructor.
Auto Dagger allows you to annotate a Kotlin object with @Replaces
without it being provided in the graph. This is especially useful for tests:
@Replaces(ThreadPoolExecutor::class)
object DirectExecutor : Executor {
override fun execute(command: Runnable) {
command.run()
}
}
If the target type is annotated with AutoInitialize, then an empty module will be generated to replace the auto initialize module, effectively disabling it.
// In your `main` source set
interface Repository
@AutoBind(asTypes = [Repository::class])
@AutoBindIntoSet(asTypes = [Closeable::class])
@Singleton
class RealRepository @Inject constructor() : Repository, Closeable {
override fun close() {}
}
// In your `test` source set
// Since `FakeRepository` doesn't implement `Closeable` then it's
// not bound as `Closable` and the real `RealRepository -> Closeable`
// binding is removed.
@Replaces(RealRepository::class)
class FakeRepository @Inject constructor() : Repository
0.3
Specifies how generic supertypes should be bound. Defaults to BindGenericAs.Type.
Which component to install the binding in. Defaults to being inferred based on the scope.
A version of AutoBind that binds the object using IntoMap. The object must also be annotated with a MapKey annotated annotation such as StringKey, MapKey, or a custom annotation.
For more documentation on auto bind see AutoBind.
See also https://dagger.dev/dev-guide/multibindings.html#map-multibindings
0.2
Which component to install the binding in. Defaults to being inferred based on the scope.
Specifies which supertypes to bind the object as. Required if there are multiple supertypes.
Specifies how generic supertypes should be bound. Defaults to BindGenericAs.Type.
Specifies how generic supertypes should be bound. Defaults to BindGenericAs.Type.
Which component to install the binding in. Defaults to being inferred based on the scope.
A version of AutoBind that binds the object using IntoSet.
For more documentation on auto bind see AutoBind.
See also Set Multibindings
0.2
Which component to install the binding in. Defaults to being inferred based on the scope.
Specifies which supertypes to bind the object as. Required if there are multiple supertypes.
Specifies how generic supertypes should be bound. Defaults to BindGenericAs.Type.
Which component to install the binding in. Defaults to being inferred based on the scope.
Instructs Auto Dagger to automatically bind the annotated type as its parent type.
To use this annotation the class must:
Not be generic - To bind generic types implement your own binding that provides the type arguments.
Have exactly one direct supertype - If you have multiple supertypes then specify which to bind using asTypes.
Only direct supertypes can be bound. For example, if your class implements Closeable
you cannot bind it as AutoCloseable
(which is a supertype of Closeable
). To work around this, add the bound type as an explicit supertype.
interface Repository
@AutoBind
@Singleton
class RealRepository @Inject constructor() : Repository
// Generates the equivalent to:
@Binds
abstract fun RealRepository.bindRealRepositoryAsRepository(): Repository
Auto Dagger tries to infer the component based on the scope of the object using the following mapping:
Scope | Component |
---|---|
No scope | SingletonComponent |
Singleton | SingletonComponent |
Reusable | SingletonComponent |
ActivityRetainedScoped | ActivityRetainedComponent |
ActivityScoped | ActivityComponent |
FragmentScoped | FragmentComponent |
ServiceScoped | ServiceComponent |
ViewScoped | ViewComponent |
ViewModelScoped | ViewModelComponent |
ViewWithFragmentScoped | ViewWithFragmentComponent |
If you want to install the binding in a different component or if you're using a custom scope, then you can use the inComponent parameter to explicit provide the component.
If you have multiple supertypes use the asTypes parameter to specify which of them to bind. You only need to specify the raw class name if the type is generic (i.e. if your type implements Callable<Stuff>
you pass asTypes = [Callable::class]
to indicate you want to bind it).
Normally the bound object needs to be provided to the dependency graph using either an @Provides
annotated method or using an @Inject
annotated constructor.
Auto Dagger allows you to annotate a Kotlin object with @AutoBind
without it being provided in the graph. This is especially useful for tests:
@AutoBind
object DirectExecutor : Executor {
override fun execute(command: Runnable) {
command.run()
}
}
To bind the object using multibinding, use AutoBindIntoSet and/or AutoBindIntoMap. These can be used at the same time as AutoBind.
Any Qualifiers on the annotated type will be carried over to the binding:
@Named("Prod")
@AutoBind
class ProdAuthenticator @Inject constructor() : Authenticator
// Generates the equivalent to:
@Binds @Named("Prod")
abstract fun ProdAuthenticator.bindProdAuthenticatorAsAuthenticator(): Authenticator
0.2
Which component to install the binding in. Defaults to being inferred based on the scope.
Specifies which supertypes to bind the object as. Required if there are multiple supertypes.
A class that can initialize multiple Initializable in order of their priority.
0.2
Initializes the provided Initializable. This method is thread safe and calling it multiple times will only initialize the initializables once.
Returns a new Initializable with the given priority.
If the initializer has been initialized or not (i.e. if initialize has been called).
Initializes the provided Initializable. This method is thread safe and calling it multiple times will only initialize the initializables once.
If any initializable throws an exception the remaining initializes are still initialized before rethrowing the exception. If multiple initializables throw then the first one is thrown with the other exceptions added as suppressed exceptions.
If this method fails, calling it again will complete successfully without attempting to initialize the failed initializables again.
If the initializer has been initialized or not (i.e. if initialize has been called).
Marks the given objects as being initializable.
This will instruct Auto Dagger to provide the object as an Initializable which allows you to use AutoDaggerInitializer to later initialize the annotated objects.
If the object implements the Initializable interface then it will be created when AutoDaggerInitializer is injected and Initializable.initialize will be called when AutoDaggerInitializer.initialize is called.
Otherwise, the object is only created when AutoDaggerInitializer.initialize is called.
0.2
The type is bound as the exact supertype and as a wildcard type. For example, if the type is List<String>
then it's bound as both List<String>
and List<*>
.
Only the exact supertype is bound. For example, if the type is List<String>
then only List<String>
is bound.
This is the default.
The type is bound as a wildcard type. For example, if the type is List<String>
then it's bound as List<*>
.
How generic types are bound when using multibinding such as AutoBindIntoSet or AutoBindIntoMap.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
if this enum type has no constant with the specified name
Returns an array containing the constants of this enum type, in the order they're declared.
This method may be used to iterate over the constants.
Converts the provided Lazy into an Initializable with the given priority (see AutoInitialize.priority).
When the returned Initializable is initialized, the lazy value is computed.
0.2
Converts the provided Lazy into an Initializable with the given priority (see AutoInitialize.priority).
Returns a new Initializable with the given priority.
Returns a new Initializable with the given priority.
0.2
An interface used to indicate that initialization isn't done when the object is created but rather when calling initialize.
This is useful if you want to be able to test your object.
Although you can use this interface by itself, it's meant to be used in conjunction with AutoInitialize.
0.2
Initializes the initializable.
Returns a new Initializable with the given priority.
Initializes the initializable.
A version of AutoBind that binds the object using IntoMap. The object must also be annotated with a MapKey annotated annotation such as StringKey, MapKey, or a custom annotation.
A version of AutoBind that binds the object using IntoSet.
A class that can initialize multiple Initializable in order of their priority.
Marks the given objects as being initializable.
How generic types are bound when using multibinding such as AutoBindIntoSet or AutoBindIntoMap.
An interface used to indicate that initialization isn't done when the object is created but rather when calling initialize.