VPPJavac

Description

Substitute for the Javac task with integrated preprocessing.

VPPJavac simply inserts a preprocessing step just before compilation that, in effect, treats each source file as a Velocity template. The preprocessed result is written to a temporary directory (the location of which you may specify) so as not to overwrite the original files.

In addition, VPPJavac also inserts an instance of VPPTool into the Velocity Context that allows you to access information about the source and destination files and encodings used for each file copied. It can be accessed through the key, vpp.

VPPJavac may be freely substituted wherever you used javac, but be aware that # and $ characters must be escaped (use the \ character) or Velocity will consume them.

Parameters

VPPJavac supports all of Javac's parameters in addition to the following:

Name Description Required Legal Values
([] indicates the default, if applicable)
preprocess Turns preprocessing on or off. No [Yes], No
prepdir Sets the directory used for preprocessor output. This directory will be created if it does not exist. No A directory path. [vppjavac.out]
keep If yes, then the prepdir will be deleted upon completion, else the directory will be deleted. No Yes

Parameters Specified as Nested Elements

In addition to all of Javac's parameters, VPPJavac also supports all of Javac's parameters specified as nested elements, in addition to the following:

config

By specifying this nested element, you can configure the Velocity Engine and Context used when preprocessing. See VPPConfig for a detailed description.

Examples

Note: the following examples assume that VPPJavac is being used as an antlib, hence the tasks use the vpp namespace. If not using as an antlib, then simply omit the ':' character and the xmlns attribute.
  <vpp:javac
    srcdir="${src}"
    destdir="build/classes"
    classpath="xyz.jar"
  />

first preprocesses then compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory.

  <vpp:javac
    srcdir="${src}"
    destdir="build/classes"
    classpath="xyz.jar"
    keep="yes"
    prepdir="/temp/vppjavac.out"
    preprocess="yes"
  />

preprocesses and compiles as above, but explicity sets the keep, prepdir and preprocess attributes.

  <vpp:javac
    srcdir="${src}"
    destdir="build/classes"
    classpath="xyz.jar"
    xmlns:vpp="antlib:foundrylogic.vpp"
  >
    <config>
      <context>
        <property name="foo" value="bar" />
      </context>
    </config>
  </vpp:javac>

preprocesses and compiles as in the first example, but adds a Velocity Context property called foo.