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:
EXPORT ANT_HOME=<ant_path>
EXPORT PATH=$PATH:<ant_path>/bin
Enterprise Developer 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 Micro Focus Enterprise Developer UNIX Components, the application is built on the machine running Ant.
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 $COBDIR/lib/mfant.jar -f .cobolBuild -Dmf.buildThreadCount=2
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%;$COBDIR\bin\mfant.jar
-logger com.microfocus.ant.CommandLineLoggerAlternatively, you can specify the -logger option as an environment variable as follows:
set ANT_ARGS=-logger com.microfocus.ant.CommandLineLogger
export ANT_ARGS=-logger com.microfocus.ant.CommandLineLogger
You can build specific files, instead of the entire project, using the -DfilesList parameter:
ant -lib $COBDIR/lib/mfant.jar -f .cobolBuild -DfilesList="<list-of-files>" <build-config-name>.FileCompile
where <list-of-files> is a comma delimited list of program names (including their path relative to the project directory, if applicable), and <build-config-name> is the name of the active build configuration of the project that is set in
. (Note: in cases where the active build configuration name contains spaces, <build-config-name> is the build configuration name with spaces replaced with underscores.)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: