Class TinderGeneratorTask

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
ca.uhn.fhir.tinder.ant.TinderGeneratorTask
All Implemented Interfaces:
Cloneable

public class TinderGeneratorTask extends org.apache.tools.ant.Task
/** Generate files from FHIR resource/composite metadata using Velocity templates.

Generates either source or resource files for each selected resource or composite data type. One file is generated for each selected entity. The files are generated using a Velocity template that can be taken from inside the hapi-timder-plugin project or can be located in other projects

The following Ant task properties are used

Ant Properties
Attribute Description Required
version The FHIR version whose resource metadata is to be used to generate the files
Valid values: dstu2 | dstu3 | r4 | r5
Yes
projectHome The project's base directory. This is used to possibly locate other assets within the project used in file generation. No. Defaults to: ${basedir}/..
generateResources Should files be generated from FHIR resource metadata?
Valid values: true | false
At least one of these four options must be specified as true
generateDataTypes Should files be generated from FHIR composite data type metadata?
Valid values: true | false
generateValueSets Should files be generated from FHIR value set metadata?
This option can only be used if generating multiple files (one file per value-set.)
Valid values: true | false
generateProfiles Should files be generated from FHIR profile metadata?
This option can only be used if generating multiple files (one file per profile.)
Valid values: true | false
resourceSource Which source of resource definitions should be processed? Valid values are:
  • spreadsheet  to cause resources to be generated based on the FHIR spreadsheets
  • model  to cause resources to be generated based on the model structure classes. Note that generateResources is the only one of the above options that can be used when model is specified.
No. Defaults to: spreadsheet
Java source files can be generated for FHIR resources or composite data types. Source files can be generated for each selected entity or a single source file can be generated containing all of the selected entity. The following configuration properties control the naming of the generated source files:

The following properties will be used when generating multiple source files:
    <targetSourceDirectory>/<targetPackage>/<filenamePrefix>element-name<filenameSuffix>
    where: element-name is the "title-case" name of the selected resource or composite data type.

The following properties will be used when generating a single source file:
    <targetSourceDirectory>/<targetPackage>/<targetFile>

Note that all dots in the targetPackage will be replaced by the path separator character when building the actual source file location. Also note that .java will be added to the filenameSuffix or targetFile if it is not already included.

targetSourceDirectory The source directory to contain the generated Java packages and classes. Yes when Java source files are to be generated
targetPackage The Java package that will contain the generated classes. This package is generated in the <targetSourceDirectory> if needed. Yes when targetSourceDirectory is specified
packageBase The base Java package for related classes. This property can be used to reference class in other places in a folder structure. No
targetFile The name of the file to be generated Yes when generating a single file containing all selected elements
filenamePrefix The prefix string that is to be added onto the beginning of the resource or composite data type name to become the Java class name or resource file name. No
filenameSuffix Suffix that will be added onto the end of the resource or composite data type name to become the Java class name or resource file name. No
Resource (non-Java) files can also be generated for FHIR resources or composite data types. a file can be generated for each selected entity or a single file can be generated containing all of the selected entity. The following configuration properties control the naming of the generated files:

The following properties will be used when generating multiple files (one for each selected element):
    <targetResourceDirectory>/<targetFolder>/<filenamePrefix>element-name<filenameSuffix>
    where: element-name is the "title-case" name of the selected resource or composite data type.

The following properties will be used when generating a single file containing all selected elements:
    <targetResourceDirectory>/<targetFolder>/<targetFile>

targetResourceDirectory The resource directory to contain the generated files. Yes when resource files are to be generated
targetFolder The folder within the targetResourceDirectory where the generated files will be placed. This folder is generated in the <targetResourceDirectory> if needed. No
template The path of one of the Velocity templates contained within the hapi-tinder-plugin Maven plug-in classpath that will be used to generate the files. One of these two options must be configured
templateFile The full path to the Velocity template that is to be used to generate the files.
velocityPath When using the templateFile option, this property can be used to specify where Velocity macros and other resources are located. No. Defaults to same directory as the template file.
velocityProperties Specifies the full path to a java properties file containing Velocity configuration properties No.
includeResources A list of the names of the resources or composite data types that should be used in the file generation No. Defaults to all defined resources except for DSTU2, the Binary resource is excluded and for DSTU3, the Conformance resource is excluded.
excludeResources A list of the names of the resources or composite data types that should excluded from the file generation No.
valueSetFiles A list of files containing value-set resource definitions to be used. No. Defaults to all defined value-sets that are referenced from the selected resources.
profileFiles A list of files containing profile definitions to be used. No. Defaults to the default profile for each selected resource
Author:
Bill Denton
  • Constructor Details

    • TinderGeneratorTask

      public TinderGeneratorTask()
  • Method Details

    • cleanup

      protected void cleanup()
    • execute

      public void execute() throws org.apache.tools.ant.BuildException
      Overrides:
      execute in class org.apache.tools.ant.Task
      Throws:
      org.apache.tools.ant.BuildException
    • setExcludeResources

      public void setExcludeResources(String names)
    • setFilenamePrefix

      public void setFilenamePrefix(String filenamePrefix)
    • setFilenameSuffix

      public void setFilenameSuffix(String filenameSuffix)
    • setGenerateDatatypes

      public void setGenerateDatatypes(boolean generateDatatypes)
    • setGenerateProfiles

      public void setGenerateProfiles(boolean generateProfiles)
    • setGenerateResources

      public void setGenerateResources(boolean generateResources)
    • setGenerateValueSets

      public void setGenerateValueSets(boolean generateValueSets)
    • setIncludeResources

      public void setIncludeResources(String names)
    • setPackageBase

      public void setPackageBase(String packageBase)
    • setProjectHome

      public void setProjectHome(String projectHome)
    • getResourceSource

      public String getResourceSource()
    • setResourceSource

      public void setResourceSource(String resourceSource)
    • setTargetFile

      public void setTargetFile(String targetFile)
    • setTargetFolder

      public void setTargetFolder(String targetFolder)
    • setTargetPackage

      public void setTargetPackage(String targetPackage)
    • setTargetResourceDirectory

      public void setTargetResourceDirectory(File targetResourceDirectory)
    • setTargetSourceDirectory

      public void setTargetSourceDirectory(File targetSourceDirectory)
    • setTemplate

      public void setTemplate(String template)
    • setTemplateFile

      public void setTemplateFile(File templateFile)
    • setValueSetFiles

      public void setValueSetFiles(String names)
    • setVelocityPath

      public void setVelocityPath(String velocityPath)
    • setVelocityProperties

      public void setVelocityProperties(String velocityProperties)
    • setVerbose

      public void setVerbose(boolean verbose)
    • setVersion

      public void setVersion(String version)
    • validateAttributes

      protected void validateAttributes() throws org.apache.tools.ant.BuildException
      Throws:
      org.apache.tools.ant.BuildException