Blueprint

abstract class Blueprint(data: FoundationData)

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.

Constructors

Link copied to clipboard
constructor(data: FoundationData)

Properties

Link copied to clipboard
val applicationComponentsExtension: ApplicationAndroidComponentsExtension?

Returns the ApplicationAndroidComponentsExtension associated with the project, if it exists.

Link copied to clipboard
val dynamicFeatureComponentsExtension: DynamicFeatureAndroidComponentsExtension?

Returns the DynamicFeatureAndroidComponentsExtension associated with the project, if it exists.

Link copied to clipboard
val intermediates: Directory

Returns the intermediates directory for the blueprint.

Link copied to clipboard
lateinit var javaSources: Directory

The directory where the Java source code for the blueprint is generated.

Link copied to clipboard
lateinit var kotlinSources: Directory

The directory where the Kotlin source code for the blueprint is generated.

Link copied to clipboard
val libraryComponentsExtension: LibraryAndroidComponentsExtension?

Returns the LibraryAndroidComponentsExtension associated with the project, if it exists.

Link copied to clipboard
open val name: String

Returns the name of the blueprint.

Link copied to clipboard
lateinit var namespace: String

The namespace for the generated code.

Link copied to clipboard
lateinit var packageName: String

The package name for the generated code.

Link copied to clipboard
open val packageNameSuffix: String? = null

Returns the package name suffix for the generated code, if it exists.

Link copied to clipboard
val project: Project

Accesses the project associated with the blueprint.

Link copied to clipboard
lateinit var resourcesSources: Directory

The directory where the Android resource files for the blueprint are generated.

Link copied to clipboard
lateinit var resSources: Directory

The directory where the Android resources for the blueprint are generated.

Functions

Link copied to clipboard
open fun apply()

Applies the blueprint to the project.

Link copied to clipboard
open fun CommonExtension<*, *, *, *, *, *>.finalizeDsl()

Called when the Gradle DSL for the ApplicationExtension, LibraryExtension, or DynamicFeatureAndroidComponentsExtension is finalized.

Link copied to clipboard
open fun isEnabled(): Boolean

Indicates whether the blueprint is enabled.

Link copied to clipboard
fun java(variant: String): Directory

Generates a directory for Java source code for the specified variant.

Link copied to clipboard
fun kotlin(variant: String): Directory

Generates a directory for Kotlin source code for the specified variant.

Link copied to clipboard
fun onCreate()

Called when Querent creates a new instance of the blueprint.

Link copied to clipboard
@CallSuper
open fun onVariants(variant: Variant)

Called for each variant of the project.

Link copied to clipboard
fun res(variant: String): Directory

Generates a directory for Android resources for the specified variant.

Link copied to clipboard
fun resources(variant: String): Directory

Generates a directory for Android resource files for the specified variant.