Using source files from outside your project

You can create links to sources that are outside the project, thereby saving you from copying the sources into the project, and enabling to share resources with others. Linking to COBOL copybooks or copybook projects can be useful, particularly if the copybooks are used by multiple projects.

Project dependencies

When a project uses sources from another project or build artefacts generated by another project, the project that contains the sources or generates the artefacts is referred to as a project dependency of the project that uses them.

COBOL projects can depend on other COBOL projects. Java projects can depend on Java and JVM COBOL projects. JVM COBOL projects can depend on JVM COBOL and Java projects.

There are two main types of project dependencies.

Source dependency
When Project A uses a source (a copybook, for example) from Project B, Project B is a dependency of Project A and the dependency created is a source dependency.

When you add a dependant project (Project B) all its copybook paths are added to the copybook paths of the project (Project A) and thus allows using any copybook from Project B in Project A.

Build artefacts dependency
When Project A uses build artefacts from Project B, Project B is a dependency of Project B and the dependency is called build artefacts dependency.

An example of build artefact dependency is when an .exe file from Project A loads a .dll from Project B at runtime or when an .exe file from Project A links statically a .dll from Project B.

Regardless of the dependency type, the build order of the projects changes automatically to ensure that dependent projects will be built first. Thus when Project B is a dependency of Project A, Project B is built first. This is needed to ensure that the build artefacts of Project B are up-to-date before Project A uses them.

To check the build order open Window > Preferences > General > Workspace > Build Order.

Linking to copybooks or sources

Tip: Linked resources are an Eclipse concept and are supported for COBOL projects, but Micro Focus recommends you use project dependencies where possible, and create projects to contain the resources and define an appropriate dependency between them.

You can link to individual source files and to folders containing sources. You can specify absolute paths to the sources. Alternatively, you can use a variable to define a path and then you can link to sources using a relative path. Linked resources like these show in the project in the COBOL Explorer as file icons decorated with a square with an arrow link.

In addition, you can create a copybook project or remote copybook project, and link to the project rather than individual copybooks it contains.

You can define the order in which folders and projects are searched for copybooks, by defining it in the project's properties.

Linked resources are built in the background, just like other files in the project. You can see this happening in the COBOL Build console. As with any other file, you can choose to ignore linked resources when you build.