Class LarkBatisExtension

java.lang.Object
io.github.larkbatis.gradle.LarkBatisExtension

public abstract class LarkBatisExtension extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.gradle.api.provider.Property<Boolean>
    Whether the plugin passes -parameters to compileJava.
    abstract org.gradle.api.provider.Property<Boolean>
    Whether the plugin adds io.github.larkbatis:larkbatis-processor to the annotationProcessor configuration automatically.
    abstract org.gradle.api.file.DirectoryProperty
    Directory scanned (recursively) for mapper XML.
    abstract org.gradle.api.file.ConfigurableFileCollection
    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.
    abstract org.gradle.api.provider.Property<Boolean>
    false makes 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 generated LarkBatisMappers registry class.
    abstract org.gradle.api.provider.Property<Boolean>
    false suppresses the generated Spring @Configuration.
    abstract org.gradle.api.provider.Property<String>
    Package for the generated Spring @Configuration class.
    abstract org.gradle.api.provider.Property<String>
    A default handler per Java type: javaType:handlerClass pairs separated by commas — the build-time answer to a mybatis-config.xml <typeHandlers> block.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 at src/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 is src/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

      public abstract org.gradle.api.provider.Property<Boolean> getAddProcessorDependency()
      Whether the plugin adds io.github.larkbatis:larkbatis-processor to the annotationProcessor configuration automatically. Switch off to manage the processor version yourself.
    • getAddParametersFlag

      public abstract org.gradle.api.provider.Property<Boolean> getAddParametersFlag()
      Whether the plugin passes -parameters to compileJava. 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 sees arg0 — 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 @Param on every mapper parameter, which needs no parameter names at all.

    • getMapUnderscoreToCamelCase

      public abstract org.gradle.api.provider.Property<Boolean> getMapUnderscoreToCamelCase()
      false makes 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 to true.

      Passed as -Alarkbatis.mapUnderscoreToCamelCase.

    • getTypeHandlers

      public abstract org.gradle.api.provider.Property<String> getTypeHandlers()
      A default handler per Java type: javaType:handlerClass pairs separated by commas — the build-time answer to a mybatis-config.xml <typeHandlers> block.

      Passed as -Alarkbatis.typeHandlers.

    • getRegistryPackage

      public abstract org.gradle.api.provider.Property<String> getRegistryPackage()
      Package for the generated LarkBatisMappers registry class. When unset, the processor picks the common package prefix of all mappers.

      Passed as -Alarkbatis.registryPackage.

    • getSpringConfig

      public abstract org.gradle.api.provider.Property<Boolean> getSpringConfig()
      false suppresses the generated Spring @Configuration. When unset, the processor emits it when spring-context is on the build classpath.

      Passed as -Alarkbatis.springConfig.

    • getSpringConfigPackage

      public abstract org.gradle.api.provider.Property<String> getSpringConfigPackage()
      Package for the generated Spring @Configuration class. When unset, it lands in the same package as the registry.

      Passed as -Alarkbatis.springConfigPackage.