Beagle must know all components (Widgets, Actions, Operations, Logger, …) that you define in your project in order to work properly.
Although it’s possible to create your own implementation of BeagleSdk
class and register the components, Beagle annotation processor can save you a lot of time. It uses Beagle annotations to generate an implementation of BeagleSdk
interface called BeagleSetup
that gathers all annotated components in your project.
In order to add Beagle Annotation Processor to your project, you must follow the given steps:
apply plugin: 'kotlin-kapt'
dependencies {
kapt "br.com.zup.beagle:android-processor:$beagle_version"
}
Beagle annotation processor can find components annotated in your project and its dependencies. To work properly, all modules or dependencies that annotate components with Beagle annotations must include Beagle annotation processor in its dependencies.
Beagle annotation processor accepts two parameters:
They can be used as follow:
kapt {
arguments {
arg("beagle.moduleName", "sample")
arg("beagle.generateSetupClasses", "false")
}
}
This parameter is used to give meaningful names to some generated classes. It isn’t mandatory, but we strongly recommend using it.
Dynamic generated classes names will look like: RegisteredActionsRegistrar59c20e58331c4f11b84d377475593739
. This makes it difficult to tell which module these classes come from.
By default, every module that uses Beagle annotation processor generate the BeagleSetup
class. This is a problem when you want to create a module that, for instance, will have only widgets.
BeagleSetup
class declares a property of BeagleConfig
type that can’t be null and we end up having to register a dummy BeagleConfig
class inside that module. It leads to the following problem: This implementation of BeagleConfig
will conflict with the official BeagleConfig
implementation of your project, because you can have one and only one BeagleConfig
implementation within your project.
To solve this situation, it’s possible to disable BeagleSetup
class generation in modules where it’s not needed. This is done by adding the following kapt argument to the module’s gradle file:
kapt {
arguments {
arg("beagle.generateSetupClasses", "false")
}
}
Some properties are unique in a Beagle project. This means that only one component of that type can be registered on your entire project structure (including other modules and dependencies that use Beagle annotation processor). Properties that are unique includes:
If you register a component that should be unique twice on your project structure, Beagle annotation processor will complain and your project will not compile. Error message will look like:
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.