Class LarkBatisExtension
larkbatis { ... } build-script configuration.
larkbatis {
mapperDir = layout.projectDirectory.dir("src/main/mappers") // default: src/main/resources
mapperDirs.from("src/main/legacy-mappers") // default: empty
addProcessorDependency = false // default: true
addParametersFlag = false // default: true
mapUnderscoreToCamelCase = false // default: processor default (true)
typeHandlers = "com.example.Money:com.example.MoneyHandler" // default: none
registryPackage = "com.example.app" // default: processor default
springConfig = false // default: processor default
springConfigPackage = "com.example.config" // default: processor default
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract org.gradle.api.provider.Property<Boolean>Whether the plugin passes-parameterstocompileJava.abstract org.gradle.api.provider.Property<Boolean>Whether the plugin addsio.github.larkbatis:larkbatis-processorto theannotationProcessorconfiguration automatically.abstract org.gradle.api.file.DirectoryPropertyDirectory scanned (recursively) for mapper XML.abstract org.gradle.api.file.ConfigurableFileCollectionFurther directories scanned the same way, for a module whose mapper XML does not live under one root — rewritten mappers kept beside the legacy ones, or generated mapper XML under the build directory.abstract org.gradle.api.provider.Property<Boolean>falsemakes underscores significant when a ResultSet label is matched to a property — the behaviour MyBatis has with its setting of the same name off.abstract org.gradle.api.provider.Property<String>Package for the generatedLarkBatisMappersregistry class.abstract org.gradle.api.provider.Property<Boolean>falsesuppresses the generated Spring@Configuration.abstract org.gradle.api.provider.Property<String>Package for the generated Spring@Configurationclass.abstract org.gradle.api.provider.Property<String>A default handler per Java type:javaType:handlerClasspairs separated by commas — the build-time answer to amybatis-config.xml<typeHandlers>block.
-
Constructor Details
-
LarkBatisExtension
public LarkBatisExtension()
-
-
Method Details
-
getMapperDir
public abstract org.gradle.api.file.DirectoryProperty getMapperDir()Directory scanned (recursively) for mapper XML. Only files whose root element is<mapper>are picked up, so pointing this atsrc/main/resources— the default — is safe next to other XML.Unset by default rather than conventioned to the resources directory, because the default has to disappear when
getMapperDirs()names directories of its own: a build that lists two mapper trees should scan those two, not those two plus a resources directory it never mentioned. -
getMapperDirs
public abstract org.gradle.api.file.ConfigurableFileCollection getMapperDirs()Further directories scanned the same way, for a module whose mapper XML does not live under one root — rewritten mappers kept beside the legacy ones, or generated mapper XML under the build directory.Every namespace found still has to name a mapper interface compiled in this module; a directory outside it is only useful when the interfaces are here too, and any file that matches nothing is reported and ignored.
The scanned set is
getMapperDir()followed by this collection, duplicates removed; when neither is set it issrc/main/resources. Two directories declaring the same mapper namespace is a compile error, not a last-one-wins merge — nothing here overrides anything, so there is no order to learn.larkbatis { mapperDirs.from("src/main/mappers", "src/main/legacy-mappers") } -
getAddProcessorDependency
Whether the plugin addsio.github.larkbatis:larkbatis-processorto theannotationProcessorconfiguration automatically. Switch off to manage the processor version yourself. -
getAddParametersFlag
Whether the plugin passes-parameterstocompileJava. On by default, and switching it off is a decision to understand first.Gradle's incremental annotation processing re-runs an aggregating processor over unchanged mappers from their class files, and a parameter name only survives into a class file when it was compiled with this flag. Without it a full build resolves
#{name}and the next incremental build seesarg0— the same source, two outcomes, decided by whether the file happened to be touched.The alternative for a build that cannot carry the flag is
@Paramon every mapper parameter, which needs no parameter names at all. -
getMapUnderscoreToCamelCase
falsemakes underscores significant when a ResultSet label is matched to a property — the behaviour MyBatis has with its setting of the same name off. The processor defaults totrue.Passed as
-Alarkbatis.mapUnderscoreToCamelCase. -
getTypeHandlers
A default handler per Java type:javaType:handlerClasspairs separated by commas — the build-time answer to amybatis-config.xml<typeHandlers>block.Passed as
-Alarkbatis.typeHandlers. -
getRegistryPackage
Package for the generatedLarkBatisMappersregistry class. When unset, the processor picks the common package prefix of all mappers.Passed as
-Alarkbatis.registryPackage. -
getSpringConfig
falsesuppresses the generated Spring@Configuration. When unset, the processor emits it when spring-context is on the build classpath.Passed as
-Alarkbatis.springConfig. -
getSpringConfigPackage
Package for the generated Spring@Configurationclass. When unset, it lands in the same package as the registry.Passed as
-Alarkbatis.springConfigPackage.
-