Annotation processing¶
Contents
Doma uses Pluggable Annotation Processing API at compile time.
In this document, we describe the options for the annotation processors in Doma and show you how to pass them to build tools.
Options¶
- doma.dao.package
- The package that the generated implementation classes of interfaces annotated with
@Dao
belong to. The specified value overrides the value of doma.dao.subpackage. The default value is the same package as the one the interfaces annotated with@Dao
belong to. - doma.dao.subpackage
- The subpackage that the generated implementation classes of interfaces annotated with
@Dao
belong to. The specified value is overridden by the value of doma.dao.package. If this value isimpl
and the package of interfaces annotated with@Dao
isexample.dao
, the generated implementation classes belong to the packageexample.dao.impl
. - doma.dao.suffix
- The name suffix that the generated implementation classes of interfaces annotated with
@Dao
have. If this value isBean
and the simple name of the interface annotated with@Dao
isEmployeeDao
, the simple name of the generated implementation class isEmployeeDaoBean
. The default value isImpl
. - doma.debug
- Whether to output the debug log in annotation processing.
If the value is
true
, the annotation processors output the debug log. The default value isfalse
. - doma.domain.converters
- The full qualified names of the classes annotated with
@DomainConverters
. The names are described as comma separated list. This value are used to find external domain classes. - doma.entity.field.prefix
- The name prefix that the fields of the generated entity meta classes have.
The value
none
means the prefix is not used. The default value is$
. - doma.expr.functions
- The full qualified name of the class that implements
org.seasar.doma.expr.ExpressionFunctions
. The default value isorg.seasar.doma.expr.ExpressionFunctions
. This value are used to determine which functions are available in expression comments. - doma.resources.dir
- The resource directory that contains the resource files such as a doma.compile.config file and sql files. Specify the value as an absolute path. If the value is not specified, the resource directory is same as the directory the classes are generated.
- doma.sql.validation
- Whether to validate the existence of sql files and the grammar of sql comments.
If the value is
true
, the validations run. To disable the validations, setfalse
. The default value istrue
. - doma.version.validation
- Whether to validate the versions of doma.jar between runtime and compile-time.
If the value is
true
, the validation runs. To disable the validation, setfalse
. The default value istrue
. - doma.config.path
- The file path of the configuration file for Doma.
The default value is
doma.compile.config
.
Setting options in Gradle¶
Use the compilerArgs property:
compileJava {
options {
compilerArgs = ['-Adoma.dao.subpackage=impl', '-Adoma.dao.suffix=Impl']
}
}
Setting options in IntelliJ IDEA¶
Import your project as a Gradle project. In the case, the options written in build.gradle are used.
Setting options in Eclipse¶
Use the Gradle plugin com.diffplug.eclipse.apt and the processorArgs property:
plugins {
id 'com.diffplug.eclipse.apt' version '3.22.0'
}
compileJava {
aptOptions {
processorArgs = [
'doma.dao.subpackage' : 'impl', 'doma.dao.suffix' : 'Impl'
]
}
}
When you run gradle eclipse
, eclipse setting files are generated.
Setting options with configuration file¶
The options specified in the doma.compile.config
file are available in all build tools
such as Eclipse, IDEA, Gradle and so on.
The doma.compile.config
file must follow the properties file format
and be placed in the root directory such as src/main/resources
.
Note
The options specified in the doma.compile.config
file are overridden by
the ones specific to the build tools.