Highlighted
Absent Member.
Absent Member.
1276 views

Cobol Ant Task

Hello,

I do have an JVMCobol Project with some thousand CobolFiles. The whole stuff is highly integrated with other JavaSources running in a JBOSS Application Server. The problem is the following :

- Saving one Cobol-File results in an "ANT-Run" of ".cobolBuild". The Cobol Task does not check if the source file is younger than the generated Classfile. So every file is compiled.

This takes a long time, litteraly killing the development process. 

Can somebody provide me with the attributes of the :

- Cobol-ANTTask

-MfFilelist-ANTTask

Basically I do have written an build.xml that looks like this :

<fileset id="cbl.src.files" dir="src">

    <include name="**/VSD138L.CBL"/>
    <include name="**/USERVG.CBL"/>
</fileset>

<!-- ******************************************************************* -->

<target name="init">
</target>

<target name="compile" depends="init">

    <for param="file">

        <path>
            <fileset refid="cbl.src.files"/>
        </path>

        <sequential>

            <var name="filebasename" unset="true"/>
            <basename property="filebasename" file="@{file}"/>

            <var name="filedirname" unset="true"/>
            <dirname property="filedirname" file="@{file}"/>

            <antcallback target="compile.file" return="retValue">
                <param name="filename" value="${filebasename}"/>
                <param name="dirname" value="${filedirname}"/>
            </antcallback>

        </sequential>

    </for>

</target>

<target name="compile.file">

    <echo>
        COBOL Compile fuer :
        dirname = ${dirname}
        filename = ${filename}
    </echo>

    <mfcobol destdir="${basedir}/bin" is64bit="false" forceCompile="${forceCompile}"
        failonerror="${cobolFailOnError}" genListingFile="true" debug="true" desttype="jvm">

        <mffilelist refid="cobol.copybook.locations"/>
        <mfdirlist refid="cobol.directives"/>
        <mffilelist type="srcfile" srcdir="${dirname}">
            <file name="${filename}"/>
        </mffilelist>

    </mfcobol>

</target>

The two files VSD138L and USERVG.CBL are compiled every time. Usually ANT-Compile Task do check the depency if a Source file has to be compiled. 

Regards

Michael

0 Likes
1 Reply
Highlighted
Absent Member.
Absent Member.

RE: Cobol Ant Task

In the meantime I have coded a workaround with ant-contrib. There is a Task called "outofdate" which does the dependency checking. It looks like this

 

<target name="compile" depends="init">

    <for param="file">

        <path>
            <fileset refid="cbl.src.files"/>
        </path>

        <sequential>

            <var name="filebasename" unset="true"/>
            <basename property="filebasename" file="@{file}" suffix=".CBL"/>

            <var name="filedirname" unset="true"/>
            <dirname property="filedirname" file="@{file}"/>

            <antcallback target="compile.file" return="retValue">
                <param name="filename" value="${filebasename}"/>
                <param name="dirname" value="${filedirname}"/>
            </antcallback>

        </sequential>

    </for>

    <echo>${ant.project.name} compile finished</echo>

</target>

<target name="compile.file">

    <outofdate>

        <sourcefiles>
            <pathelement path="${dirname}/${filename}.CBL"/>
        </sourcefiles>
        <targetfiles>
            <pathelement path="${basedir}/bin/de/lv1871/cobol/${filename}.class"/>
        </targetfiles>

        <sequential>

            <echo>
                COBOL Compile fuer :
                    dirname = ${dirname}
                    filename = ${filename}.CBL
            </echo>

            <mfcobol destdir="${basedir}/bin" is64bit="false" forceCompile="${forceCompile}"
                failonerror="${cobolFailOnError}" genListingFile="true" debug="true" desttype="jvm">

                <mffilelist refid="cobol.copybook.locations"/>
                <mfdirlist refid="cobol.directives"/>
                <mffilelist type="srcfile" srcdir="${dirname}">
                    <file name="${filename}.CBL"/>
                </mffilelist>

            </mfcobol>
        </sequential>

    </outofdate>

</target>

Source File is the Cobol-File and Destination File is the class File generated in $BASEDIR/bin/...... If the source File is younger than the "older" Class file the cobol Compile is started. Usually the MF-Cobol Ant Task should do this checking by default. It is a FUNDAMENTAL Feature of ant.

Kind regards

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.