<PRes...>


back

Description

Generates a Java Resource Bundle class from a properties file. Static properties such as localisation strings will be loaded faster if they are stored in a compiled class rather than a properties file. This task will convert the .properties files to Java sources which can then be compiled with the rest of the application.

The task is intended to be used before a compile task in a build process. The strings are maintained in the textual .properties files as normal and converted at the last minute in the build.

PRes is based on the standard Copy task so embedded FileSets can be used.

Installation

Place the jar in the lib directory of your ant installation and add the following line at the top of the build file

    <taskdef name="PRes" classname="mseries.ant.PRes" />

Parameters

Attribute Description Required
file The file to copy. Yes, unless a nested <fileset> element is used.
todir The directory in which to place the generated classes. Yes
flatten Ignore the directory structure of the .properties files, and copy all files into the directory specified by the todir attribute. No; defaults to false.

Examples

    <rb todir="./source" flatten="true" file="./properties/project.properties" >

Generates file project.class in directory ./source with no package header (default package) containing the values of the file ./properties/project.properties


    <PRes todir="./source">
        <fileset dir="./resources" />
    </PRes>

Recursively locates all the .properties files in the ./resources directory and generates Java source in subdirectories of ./source. If we have ./resources/mseries/Calendar/DateSelectorRB_de.properties the task will generate ./source/mseries/Calendar/DateSelectorRB_de.java with the package header mseries.Calendar


    <PRes todir="./source">
        <fileset dir="./source" />
    </PRes>

The .properties files reside in the same package structure as the application source, this task will generate class files for the properties and place them alongside the .properties files in the source structure