Before you use Apache Ant you need to perform the following set up:
Once you have Apache Ant installed, you need to configure your environment:
Windows:
SET ANT_HOME=<ant_path>
UNIX:
EXPORT ANT_HOME=<ant_path>
Windows:
SET PATH=%PATH%;<ant_path>\bin
UNIX:
EXPORT PATH=$PATH:<ant_path>/bin
Visual COBOL uses an Apache Ant script, .cobolBuild, to build COBOL projects. This script is automatically generated from the .cobolProj project file.
Existing external build scripts such as makefiles, MSBuild, shell scripts and others can build COBOL applications using .cobolBuild as an Ant build file.
If you use an Ant file from a project developed on a remote machine using the Visual COBOL Development Hub, the application is built on the machine running Ant.
ant -lib "%ProgramFiles(x86)%\Micro Focus\Visual COBOL\bin\mfant.jar" -f .cobolBuild
ant -lib $COBDIR/lib/mfant.jar -f .cobolBuild
You can compile your source code faster on multi-CPU machines if you use parallel compilation. To do this, you must add the mf.buildThreadCount=nn parameter. Where nn specifies the number of CPU threads to use:
ant -lib "%ProgramFiles(x86)%\Micro Focus\Visual COBOL\bin\mfant.jar" -f .cobolBuild -Dmf.buildThreadCount=2
ant -lib $COBDIR/lib/mfant.jar -f .cobolBuild -Dmf.buildThreadCount=2
ant -lib "%ProgramFiles(x86)%\Micro Focus\Visual COBOL\bin\mfant.jar" -f .cobolBuild -Dmf.forceCompile=false
ant -lib $COBDIR/lib/mfant.jar -f .cobolBuild -Dmf.forceCompile=false
For UNIX:
export CLASSPATH=$CLASSPATH:$COBDIR/lib/mfant.jar
For Windows:
SET CLASSPATH=%CLASSPATH%;%ProgramFiles(x86)%\Micro Focus\Visual COBOL\bin\mfant.jar
-logger com.microfocus.ant.CommandLineLoggerAlternatively, you can specify the -logger option as an environment variable as follows:
For Windows:
set ANT_ARGS=-logger com.microfocus.ant.CommandLineLogger
For UNIX:
export ANT_ARGS=-logger com.microfocus.ant.CommandLineLogger
You can set your own shell scripts as pre- or post-build events and they execute as part of the .cobolBuild Ant script before or after compiling.
To set pre- or post-build events:
If you reference variables in the Events field, you must prefix any linked resource path variables with ${pathVar. and terminate the variable with }. For example, code PROJECT_LOC as ${pathVar.PROJECT_LOC}.
Linked resources path variables are defined in the project's properties as follows: