Class GeneratorAntTask

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.mybatis.generator.ant.GeneratorAntTask
All Implemented Interfaces:
Cloneable

public class GeneratorAntTask extends org.apache.tools.ant.Task
This is an Ant task that will run the generator. The following is a sample Ant script that shows how to run the generator from Ant:
  <project default="genfiles" basedir=".">
    <property name="generated.source.dir" value="${basedir}" />
    <target name="genfiles" description="Generate the files">
      <taskdef name="mbgenerator"
               classname="org.mybatis.generator.ant.GeneratorAntTask"
               classpath="mybatis-generator-core-x.x.x.jar" />
      <mbgenerator overwrite="true" configfile="generatorConfig.xml" verbose="false" >
        <propertyset>
          <propertyref name="generated.source.dir"/>
        </propertyset>
      </mbgenerator>
    </target>
  </project>
 

The task requires that the attribute "configFile" be set to an existing XML configuration file.

The task supports these optional attributes:

  • "overwrite" - if true, then existing Java files will be overwritten. if false (default), then existing Java files will be untouched and the generator will write new Java files with a unique name
  • "verbose" - if true, then the generator will log progress messages to the Ant log. Default is false
  • "contextIds" - a comma delimited list of contaxtIds to use for this run
  • "fullyQualifiedTableNames" - a comma delimited list of fully qualified table names to use for this run
Author:
Jeff Butler
  • Field Summary

    Fields inherited from class org.apache.tools.ant.Task

    target, taskName, taskType, wrapper

    Fields inherited from class org.apache.tools.ant.ProjectComponent

    description, location, project
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.tools.ant.types.PropertySet
     
    void
     
     
     
     
    boolean
     
    boolean
     
    void
    setConfigfile(String configfile)
     
    void
    setContextIds(String contextIds)
     
    void
    setFullyQualifiedTableNames(String fullyQualifiedTableNames)
     
    void
    setOverwrite(boolean overwrite)
     
    void
    setVerbose(boolean verbose)
     

    Methods inherited from class org.apache.tools.ant.Task

    bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType

    Methods inherited from class org.apache.tools.ant.ProjectComponent

    clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GeneratorAntTask

      public GeneratorAntTask()
  • Method Details

    • execute

      public void execute()
      Overrides:
      execute in class org.apache.tools.ant.Task
    • getConfigfile

      public String getConfigfile()
    • setConfigfile

      public void setConfigfile(String configfile)
    • isOverwrite

      public boolean isOverwrite()
    • setOverwrite

      public void setOverwrite(boolean overwrite)
    • createPropertyset

      public org.apache.tools.ant.types.PropertySet createPropertyset()
    • isVerbose

      public boolean isVerbose()
    • setVerbose

      public void setVerbose(boolean verbose)
    • getContextIds

      public String getContextIds()
    • setContextIds

      public void setContextIds(String contextIds)
    • getFullyQualifiedTableNames

      public String getFullyQualifiedTableNames()
    • setFullyQualifiedTableNames

      public void setFullyQualifiedTableNames(String fullyQualifiedTableNames)