To Build a Project Using Apache Ant

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. This is how you use .cobolBuild to build a project:
From a Windows command prompt:
ant -lib %ProgramFiles(x86)%\Micro Focus\Enterprise Developer\bin\mfant.jar -f .cobolBuild
From a UNIX command prompt:
ant -lib $COBDIR/lib/mfant.jar -f .cobolBuild
Note: When compiling to multiple executables from the command line, you must specify the -logger parameter to enable the correct log to be output to the console:
-logger com.microfocus.ant.CommandLineLogger
Alternatively, you can specify the -logger option as an environment variable as follows:

For Windows:

set ANT_ARGS=-logger com.microfocus.ant.CommandLineLogger


export ANT_ARGS=-logger com.microfocus.ant.CommandLineLogger
From the Eclipse IDE:
  1. Click Window > Preferences > Run/Debug > Launching and clear the Build (if required) before launching option, if you don't want to trigger an Eclipse build before each Ant build.
  2. In COBOL Explorer, right-click the .cobolBuild file and click Run As > Ant Build.

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:

  1. Right-click your project in the COBOL Explorer view and click Properties.
  2. Expand Micro Focus > Build Configurations and click Events for the desired configuration.
  3. Type the code of the script either in the Pre-build event command line or in the Post-build event command line field.
  4. Click Apply and then click OK.

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:

  1. Right-click your project in COBOL Explorer, then click Properties > Resource > Linked Resources.
  2. See the variables listed on the Path Variables tab.