Skip to content

Annotation Processor Arguments

xcesco edited this page Jan 4, 2023 · 8 revisions

Kripton Processor Annotation accepts different options:

For Java Annotation Processor:

android {
  
  defaultConfig {
    applicationId "com.abubusoft.kripton.basicsample"
    
    javaCompileOptions {
      annotationProcessorOptions {
        arguments = [
          "kripton.debug"         : "true",
          "kripton.log"           : "true",
          "kripton.schemaLocation": "${projectDir}/schemas".toString(),
          "kripton.schemaIncludeDate": "true"
        ]
    }
  }
}

For Kotlin Annotation Processor:

kapt {
   arguments {
     arg("kripton.debug", "true"),
     arg("kripton.logger", "true"),
     arg("kripton.schemaLocation","${projectDir}/schemas".toString()),
     arg("kripton.schemaIncludeDate": "true")
   }
}

The accepted arguments are:

kripton.debug = "true"/"false"

If true, enable kripton log during annotations processor's execution. This log includes info about generated classes. An example:

w: Note: Kripton Persistence Library v. 5.0.0
w: Note: param kripton.androidx = <unset>
w: Note: 	jetpack live data support is disabled
w: Note: param kripton.schemaLocation = <unset>
w: Note: 	schemas location is 'd:\projects\xxx\KotlinSample01\schemas'
w: Note: class 'ArticleBindMap' in package 'com.abubusoft.kripton.kotlin.sample01.model' 
         is generated by '@BindType' annotation processor
w: Note: class 'ChannelBindMap' in package 'com.abubusoft.kripton.kotlin.sample01.model' 
          is generated by '@BindType' annotation processor
...

The default value is false.

kripton.schemaLocation

It allows specifying in which folder are generated DataSource schemas. If not defined, the default folder <project-dir>/schemas will be used. Otherwise, you can specify another folder (relative to the project folder).

The default value is "${projectDir}/schemas".toString().

kripton.schemaIncludeDate = "true"/"false"

This argument is true, allow to include in the generated schema file the date of generation. If false, no date is inserted in file.

------------------------------------------------------------------------------------
--
-- Filename: app_schema_1.sql
-- Generated by: kripton annotation processor 8.2.0-rc.4
-- Date: Wed Jan 04 15:37:10 CET 2023
--
------------------------------------------------------------------------------------

CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT) 

The default value is true. Since version 8.2.0-rc.4.

kripton.log = "true"/"false" (default true)

This arguments, if it set as false, avoid that annotation processor generates log code. This is mainly used for ORM module. This argument override all data source's configuration on log configuration.

Just an example:

@BindDataSourceOptions(logEnabled = true, 
  populator = PersonPopulator.class, 
  cursorFactory = PersonCursorFactory.class,
  databaseLifecycleHandler = PersonLifecycleHandler.class, 
  updateTasks = {
    @BindDataSourceUpdateTask(version = 2, task = PersonUpdateTask.class) 
  })
@BindDataSource(daoSet = { DaoPerson.class }, fileName = "app.db" , log=true)
public interface AppWithConfigDataSource {

}

With this configuration, Kritpon for default will generate log statements as usual. If you want to disable log code generation just configure the annotation processor with:

javaCompileOptions {
  annotationProcessorOptions {
    arguments = [
      "kripton.log" : "false"
    ]
  }
}

It's particularly useful when you want to generate a release apk and you need to control logs generation in a centralized way.

Since version 6.0.0

The default value is true.

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally