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

  • 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