public class

GeneratorAntTask

extends Task
java.lang.Object
   ↳ org.apache.tools.ant.ProjectComponent
     ↳ org.apache.tools.ant.Task
       ↳ org.mybatis.generator.ant.GeneratorAntTask

Class Overview

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

Summary

[Expand]
Inherited Fields
From class org.apache.tools.ant.Task
From class org.apache.tools.ant.ProjectComponent
Public Constructors
GeneratorAntTask()
Public Methods
PropertySet createPropertyset()
void execute()
String getConfigfile()
String getContextIds()
String getFullyQualifiedTableNames()
boolean isOverwrite()
boolean isVerbose()
void setConfigfile(String configfile)
void setContextIds(String contextIds)
void setFullyQualifiedTableNames(String fullyQualifiedTableNames)
void setOverwrite(boolean overwrite)
void setVerbose(boolean verbose)
[Expand]
Inherited Methods
From class org.apache.tools.ant.Task
From class org.apache.tools.ant.ProjectComponent
From class java.lang.Object

Public Constructors

public GeneratorAntTask ()

Public Methods

public PropertySet createPropertyset ()

public void execute ()

Throws
BuildException

public String getConfigfile ()

Returns
  • Returns the configfile.

public String getContextIds ()

public String getFullyQualifiedTableNames ()

public boolean isOverwrite ()

Returns
  • Returns the overwrite.

public boolean isVerbose ()

public void setConfigfile (String configfile)

Parameters
configfile The configfile to set.

public void setContextIds (String contextIds)

public void setFullyQualifiedTableNames (String fullyQualifiedTableNames)

public void setOverwrite (boolean overwrite)

Parameters
overwrite The overwrite to set.

public void setVerbose (boolean verbose)