cobol

Description

Compiles one or more COBOL programs.

Parameters

Attribute Description Required
copyext Specify the filename extension of the copyfile that the compiler is to look for if a filename in a COPY statement is specified without an extension. Defaults to the COBOL compiler default "cbl,cpy".
Important: This attribute is deprecated.
Ignored
configuration The name of the active directive set configuration to be used when searching for directive set files. No
connectionName The name of the remote connection. No
debug If true, compiles a COBOL program for debugging. Defaults to false. No
destdir The name of the directory where the outputs from a compilation are to be written. Defaults to the current directory. No
destfile The name of the output file to be created for a single compilation. Must not be used if nested mffilelist elements have been specified. Defaults to the source file's base name with the appropriate .obj/.o extension. No
desttype The type of output that the COBOL compiler is to produce. The value of this attribute must be one of "obj", "int", "gnt" or "jvm". No
failonerror If true, stops the build process if the task exits with a return-code other than 0. Defaults to false. No
forcecompile If true, compiles a COBOL program even if it is not out-of-date. Defaults to false. No
genlistingfile If true, a listing file is generated during compilation. Defaults to false. No
is64bit If true, compiles a COBOL program to a 64-bit target. Defaults to false (i.e. 32-bit target). No
projectName The name of the project. No
retaindirectivesfile If true, the generated directives file is left behind after compilation. Defaults to false. No
settingsDir The name of the active directive set settings directory. No
srcdir The name of the directory where the COBOL source file(s) are to be picked up from. Defaults to the current directory. No
srcfile The name of the source file to be compiled. Must not be used if nested mffilelist elements have been specified. No
threadedrts If true, the -t (threaded) option will be passed to the UNIX compiler. Defaults to false.
Important: This attribute is applicable only on UNIX and is ignored on Windows.
No
threadCount The maximum number of parallel compilations to be used. Defaults to 1. No
useDirectiveSet If true, this indicates that the build should search for a directive set file. Defaults to false. No
userEnv The name of the properties file that contains the user specified environment variables. No
verbose If true, causes additional informational messages to be displayed by the task. Defaults to false. No
analysisData If set to standalone, the compiler only produces data to be analyzed by the code analysis task (see analysis task). No build artifacts are created. If set to atCompilation, the compiler produces both the build artifacts and the data to be analyzed by the code analysis task. If this parameter is omitted, the compiler only produces the build artifacts. No
analysisDataDir The directory where the compiler creates the data to be analyzed by the code analysis task. Must be used with the analysisData parameter in the cobol task. No

Parameters specified as nested elements

fileset
Use nested <fileset> elements to specify the source file name(s) to be compiled.
mfdirlist
Use nested <mfdirlist> elements to specify directives to be used to compile the program(s). See mfdirlist.
mffilelist
Use nested <mffilelist> elements to specify the source file name(s) to be compiled and the macro copybook. See mffilelist.

Errors and return codes

By default, the return code of a <cobol> task is ignored. When you set failonerror="true", any non-zero response is treated as an error and would mean the build exits.

Examples

Compile a single program to a 32-bit .obj/.o file, capable of being debugged:

<cobol srcfile="Program.cbl" srcdir="${basedir}" desttype="obj" destdir="${basedir}/bin" debug="true"/>

Compile a single program to a 64-bit .obj/.o file, with directives specified in a nested mfdirlist element:

<cobol srcfile="Program.cbl" srcdir="${basedir}" desttype="obj" destdir="${basedir}/bin" is64bit="true">
    <mfdirlist id="cobol.default.directives">
        <directive name="dialect" value="MF"/>
        <directive name="charset" value="ASCII"/>
    </mfdirlist>
</cobol>

Use a referenced mffilelist element to specify a set of source files that are to be compiled to .int files. Copybook locations and compiler directives are specified in referenced mffilelist and mfdirlist elements respectively:

<mfdirlist id="cobol.default.directives">
    <directive name="dialect" value="MF"/>
    <directive name="charset" value="ASCII"/>
</mfdirlist>

<mffilelist id="copybook.locations">
    <path type="copybook" name="${basedir}/copybooks"/>
</mffilelist>

<mffilelist id="source.files" srcdir="${basedir}" type="srcfile">
    <file name="Program1.cbl"/>
    <file name="Program2.cbl"/>
    <file name="Program3.cbl"/>
</mffilelist>

<cobol desttype="int" destdir="${basedir}/bin">
    <mffilelist refid="copybook.locations"/>
    <mfdirlist refid="cobol.default.directives"/>
    <mffilelist refid="source.files"/>
</cobol>