Blueprint
Abstract base class for Querent blueprints.
A blueprint is a class that defines how to generate code for a specific purpose. Blueprints are used by Querent to generate code for a variety of tasks, such as generating build profiles, XML resources, and language schemas.
The Blueprint
class provides several methods that can be used to define the code generation process. These methods include:
isEnabled()
: This method returns a boolean value that indicates whether the blueprint is enabled. If the blueprint is not enabled, its code generation methods will not be called.packageNameSuffix
: This property specifies the package name suffix for the generated code. If the property is not set, the package name suffix will be empty.onCreate()
: This method is called when Querent creates a new instance of the blueprint. The method is responsible for initializing the blueprint's properties and applying any necessary configuration.apply()
: This method is called when Querent applies the blueprint. The method is responsible for performing the code generation process.onVariants(variant: Variant)
: This method is called for each variant of the project. The method is responsible for generating code for the specified variant.
To use the Blueprint
class, you should extend it and implement the apply()
and onVariants()
methods. The apply()
method should perform the code generation process, and the onVariants()
method should generate code for each variant of the project.
Example usage:
class MyBlueprint(data: FoundationData) : Blueprint(data) {
override fun isEnabled(): Boolean = true
override fun packageNameSuffix(): String = "my"
override fun apply() {
// Generate code here
}
override fun onVariants(variant: Variant) {
// Generate code for the specified variant here
}
}
val myBlueprint = MyBlueprint(FoundationData(project = project, codeWriter = codeWriter))
myBlueprint.onCreate()
myBlueprint.apply()
This code will instantiate a new instance of the `MyBlueprint` class
and call its `onCreate()`, `apply()`, and `onVariants()` methods.
The `apply()` method will generate code for the project, and the `onVariants()`
method will generate code for each variant of the project.
Properties
Returns the ApplicationAndroidComponentsExtension associated with the project, if it exists.
Returns the DynamicFeatureAndroidComponentsExtension associated with the project, if it exists.
Returns the intermediates directory for the blueprint.
The directory where the Java source code for the blueprint is generated.
The directory where the Kotlin source code for the blueprint is generated.
Returns the LibraryAndroidComponentsExtension associated with the project, if it exists.
The package name for the generated code.
Returns the package name suffix for the generated code, if it exists.
The directory where the Android resource files for the blueprint are generated.
The directory where the Android resources for the blueprint are generated.