net.sf.jasperreports.ant
Class JRAntApiWriteTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.MatchingTask
              extended by net.sf.jasperreports.ant.JRBaseAntTask
                  extended by net.sf.jasperreports.ant.JRAntApiWriteTask
All Implemented Interfaces:
java.lang.Cloneable, org.apache.tools.ant.types.selectors.SelectorContainer

public class JRAntApiWriteTask
extends JRBaseAntTask

Ant task for batch-generating the Java source file that uses the JR API to create the report design, from compiled report template files or from source JRXML files. Works like the built-in javac Ant task.

This task can take the following arguments:

Of these arguments, the src and destdir are required. When this task executes, it will recursively scan the src and destdir looking for compiled report template files or for source JRXML report template files and it will recreate the Java source file for each of them. This task makes its file creation decision based on timestamp and only input files that have no corresponding file in the target directory or where the destination Java file is older than the input file will be processed.

Version:
$Id: JRAntApiWriteTask.java 5217 2012-04-03 15:16:10Z teodord $
Author:
Teodor Danciu (teodord@users.sourceforge.net)

Field Summary
 
Fields inherited from class net.sf.jasperreports.ant.JRBaseAntTask
jasperReportsContext
 
Fields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
fileset
 
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
JRAntApiWriteTask()
           
 
Method Summary
protected  void checkParameters()
          Checks that all required attributes have been set and that the supplied values are valid.
 org.apache.tools.ant.types.Path createClasspath()
          Adds a path to the classpath.
 org.apache.tools.ant.types.Path createSrc()
          Adds a path for source report templates.
 void execute()
          Executes the task.
protected  void runApi()
          Runs the generated code and produces the JRXML image of the report.
protected  void scanDir(java.io.File srcdir, java.io.File destdir, java.lang.String[] files)
          Scans the directory looking for source report design files to be processed.
protected  void scanSrc()
          Scans the source directories looking for source report design files to be processed.
 void setDestdir(java.io.File destdir)
          Sets the destination directory into which the Java report design files should be generated.
 void setRunApi(boolean runApi)
          If set to true, the task will run the API writer generated classes and produce JRXML source files.
 void setSrcdir(org.apache.tools.ant.types.Path srcdir)
          Sets the source directories to find the source files.
protected  void writeApi()
          Performs the API code generation for the selected report design files.
 
Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItems
 
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRAntApiWriteTask

public JRAntApiWriteTask()
Method Detail

setSrcdir

public void setSrcdir(org.apache.tools.ant.types.Path srcdir)
Sets the source directories to find the source files.

Parameters:
srcdir - source path

createSrc

public org.apache.tools.ant.types.Path createSrc()
Adds a path for source report templates.

Returns:
source path

setDestdir

public void setDestdir(java.io.File destdir)
Sets the destination directory into which the Java report design files should be generated.

Parameters:
destdir - destination directory

createClasspath

public org.apache.tools.ant.types.Path createClasspath()
Adds a path to the classpath.

Returns:
classpath to use when updating the report

setRunApi

public void setRunApi(boolean runApi)
If set to true, the task will run the API writer generated classes and produce JRXML source files.


execute

public void execute()
             throws org.apache.tools.ant.BuildException
Executes the task.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException

checkParameters

protected void checkParameters()
                        throws org.apache.tools.ant.BuildException
Checks that all required attributes have been set and that the supplied values are valid.

Throws:
org.apache.tools.ant.BuildException

scanSrc

protected void scanSrc()
                throws org.apache.tools.ant.BuildException
Scans the source directories looking for source report design files to be processed.

Throws:
org.apache.tools.ant.BuildException

scanDir

protected void scanDir(java.io.File srcdir,
                       java.io.File destdir,
                       java.lang.String[] files)
Scans the directory looking for source report design files to be processed. The results are returned in the instance variable reportFilesMap.

Parameters:
srcdir - source directory
destdir - destination directory
files - included file names

writeApi

protected void writeApi()
                 throws org.apache.tools.ant.BuildException
Performs the API code generation for the selected report design files.

Throws:
org.apache.tools.ant.BuildException

runApi

protected void runApi()
               throws org.apache.tools.ant.BuildException
Runs the generated code and produces the JRXML image of the report.

Throws:
org.apache.tools.ant.BuildException


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com