Class LarkBatisPlugin

java.lang.Object
io.github.larkbatis.gradle.LarkBatisPlugin
All Implemented Interfaces:
org.gradle.api.Plugin<org.gradle.api.Project>

public final class LarkBatisPlugin extends Object implements org.gradle.api.Plugin<org.gradle.api.Project>
Wires mapper XML into the LarkBatis annotation processor: passes -Alarkbatis.mapperDir to compileJava and registers the XML files as compile inputs, so editing a mapper file recompiles the mappers. The plugin exists because the Filer.getResource spec does not guarantee access to src/main/resources — a build-tool plugin is the reliable way to hand the processor a real directory path.

It also passes -parameters, which is not a convenience. Gradle's incremental annotation processing re-runs an aggregating processor over unchanged mappers from their class files, where a parameter name survives only if that flag was on; without it the first clean build resolves #{name} and the next incremental build fails on arg0. Wiring this by hand is exactly the step a consuming build forgets, which is why the plugin does it.

Also registers larkbatisScan, which reports what migrating a MyBatis codebase to LarkBatis would cost. It runs the scanner in its own JVM off a detached configuration, so neither the scanner nor the processor ever touches the application's classpath.

All code generation stays inside javac (larkbatis-processor); this plugin never generates sources itself and adds nothing to the application's runtime classpath.

  • Constructor Details

    • LarkBatisPlugin

      public LarkBatisPlugin()
  • Method Details

    • apply

      public void apply(org.gradle.api.Project project)
      Specified by:
      apply in interface org.gradle.api.Plugin<org.gradle.api.Project>