Before you use Apache Ant you need to perform the following set up:
export ANT_HOME=$COBDIR/remotedev/ant/apache-ant-1.9.9
export PATH=$ANT_HOME/bin:$PATH
SET ANT_HOME=<ant_path>
SET 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.
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 threadCount=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 -DthreadCount=2
ant -lib $COBDIR/lib/mfant.jar -f .cobolBuild -DthreadCount=2
ant -lib %ProgramFiles(x86)%\Micro Focus\Visual COBOL\bin\mfant.jar -f .cobolBuild -DforceCompile=false
ant -lib $COBDIR/lib/mfant.jar -f .cobolBuild -DforceCompile=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: