IBM i Applications
A repository can hold several IBM i applications that compile with different library lists. Define them in the repository's .codermake/config.json, and every object compiles with its own application's library list. Task builds and project builds choose only a stage, such as test; codermake picks each object's list from the application that owns it. One task can change objects in several applications, and each object still compiles with the right list.
Build rules follow the same definitions. One build-rules profile covers all applications, and CoderFlow analyzes each application with its own list, over its own libraries.
Start a new shop with applications: see Setting up. A shop that already compiles with the Build connection's named library lists can keep them, and can switch to applications in one change. Repositories that define no applications build exactly as before.
These applications are defined in a code repository, for compiling. For applications that Portal users launch, see IBM i Portal Applications.
Why applications
A shop's change-management tool typically defines applications. Each application builds into its own libraries and compiles with its own library list at each stage, for example test and production. Several applications can share libraries that sit high on every list, so an unqualified name resolves differently depending on the application. For example, two data libraries can hold files with the same name, or one application's overlay library comes ahead of another's.
With one library list per task, a change to a shared file that reaches programs in two applications compiles some of them against the wrong objects. Applications make the list a property of each object instead.
Concepts
| Term | Meaning |
|---|---|
| Application | A named set of library directories that compile with the same library lists |
| Library directory | A top-level directory of the repository, one per IBM i library, named after the library in lower case, such as ordlib for ORDLIB |
| Stage | A named library list that every application defines, such as test and production. Each build uses one stage |
| Library list | The user portion of the library list for one application at one stage, highest priority first, exactly as the shop defines it. QTEMP and QGPL stay wherever they are listed |
| Include path | Optional. The order in which unqualified copy members are searched across library directories for the application's objects. It is the same at every stage, so one commit compiles the same way everywhere |
Setting up
- Define the applications. Take them from your change-management tool or its documentation: each application's name, the library directories it builds, and its library list at each stage. Write them into the repository's
.codermake/config.json(see The configuration file), or ask an agent to. This can be the repository's first commit: the directories don't have to exist yet. - Import the sources. Each library is imported into the directory of its name in lower case, which is the name the applications list.
- Generate the build rules with one all-applications profile. On the Generate IBM i Build Rules page, choose All applications and the
productionstage, add overrides for any application that needs other settings, and analyze. CoderFlow analyzes each application separately and puts every application's rules in one task to review and approve. Save the profile, so that you can run it again and IBM i Import automations can run it. See Build rules for all applications. - Set the Build connection's stage. Choose Repository applications in Library Lists From, and enter the development stage, such as
test, in Applications Stage. See Repository applications.
Tasks then compile each object with its application's list at that stage, with no list to choose. IBM i deployment profiles, still in development, can name a stage in the same way.
Rules are generated at production because imports and rules generation work from production objects and sources: the repository's directories are named after the production libraries, and each object's dependencies are resolved as production resolves them.
The configuration file
Applications are defined in the repository, in the root .codermake/config.json, beside codermake's other settings. Because they live in the repository, the lists are pinned to each commit: a list change travels with the code that needs it, through review and approval like any other change. codermake uses the same file outside CoderFlow.
{
"applications": {
"ORDERS": {
"libraries": ["ordlib", "orddta"],
"libraryLists": {
"test": ["QTEMP", "COMMONT", "ORDLIBT", "ORDDTAT", "VENDOR", "QGPL"],
"production": ["QTEMP", "COMMON", "ORDLIB", "ORDDTA", "VENDOR", "QGPL"]
},
"includePath": ["common", "ordlib", "orddta"]
},
"BILLING": {
"libraries": ["billib"],
"libraryLists": {
"test": ["COMMONT", "BILLIBT", "ORDDTAT", "VENDOR"],
"production": ["COMMON", "BILLIB", "ORDDTA", "VENDOR"]
}
}
}
}
In this repository, objects in ordlib and orddta belong to ORDERS and objects in billib to BILLING. The common directory holds only copy members, which nothing builds, so it needs no application.
The rules:
- Every library directory with build targets belongs to exactly one application. An object belongs to the application whose
librarieslists its library directory. A directory that holds only copy members, includes or other sources that nothing builds needs no application. There is no default application, and there are no exceptions for single objects. A listed directory doesn't have to exist yet, so the file can be the repository's first commit. - Every application defines the same stages, with the same names, so a stage always resolves for every object. Stage names are case-sensitive.
- Lists hold IBM i library names: up to 250 each, with no repeats. Don't add the task library or a build library; CoderFlow and codermake place it themselves.
- The include path applies only to unqualified copy members (
/COPY,/INCLUDEandCOPY ... OFwithout a library). Qualified references are unaffected. Every entry must be an existing library directory. An application without one uses codermake's usual order:CODERMAKE_INCLUDE_PATHwhen it is set, otherwise every library directory alphabetically. - An application has only three settings:
libraries,libraryListsandincludePath. Anything else, including a misspelling, is an error, so a mistake isn't silently ignored.
A build target in a directory that no application lists stops the build, or a listing, with an error that names the directory. Add the directory to the libraries of the application it belongs to:
Error: Library directory 'billib' belongs to no application. List it in an application's 'libraries' in .codermake/config.json.
A file that sets defaultApplication is refused, with or without applications:
Error: .codermake/config.json: 'defaultApplication' is not supported. List every library directory that has build targets in an application's 'libraries'.
Deriving the include path
Derive each includePath once, from the application's production list. Take the production list in order, replace each library with its library directory, and leave out libraries the repository doesn't hold, such as QTEMP, QGPL and vendor libraries.
For ORDERS above, QTEMP COMMON ORDLIB ORDDTA VENDOR QGPL becomes ["common", "ordlib", "orddta"]. Don't write one per stage, and don't derive it from the test list.
Checking the file
codermake checks the whole file before it builds or lists anything, and reports the first problem, for example:
Error: .codermake/config.json: application 'BILLING' stage 'test' lists '1BILLIB', which is not a valid library name.
To check it without compiling anything, list every target with its application for each stage, from a task's terminal. A listing makes no IBM i connection:
env -u CODERMAKE_LIBRARY_LIST CODERMAKE_STAGE=production codermake --list-targets=tsv -B | cut -f1,8
env -u CODERMAKE_LIBRARY_LIST CODERMAKE_STAGE=test codermake --list-targets=tsv -B | cut -f1,8
The second column is each target's application. A target whose directory no application lists stops the listing with the error above. env -u CODERMAKE_LIBRARY_LIST matters in a task that still compiles with a named list: codermake refuses a named list in a repository that defines applications.
CoderFlow reads the file with the same rules and reports the same messages: when you save the Build connection, and when you choose applications on the Generate IBM i Build Rules page. It reads the file and never writes it.
The codermake skill, which the Build feature adds to the environment (see Skills Auto-Import), includes an applications guide. An agent can write the file from your shop's application definitions or from your existing settings, derive each include path, and check the result.
How each object's list is chosen
| Build | Stage | Each object compiles with |
|---|---|---|
| Task build | The Build connection's Applications Stage | The task library, then its application's list at that stage |
| Project build | The Applications Stage when the orchestrator was launched | The project build's library, then its application's list at that stage, read from the commit being built |
| codermake outside CoderFlow | CODERMAKE_STAGE | Its application's list at that stage |
For example, with stage test, a task that changes ordlib/ord01.pgm and billib/bil01.pgm compiles ORD01 over QTEMP COMMONT ORDLIBT ORDDTAT VENDOR QGPL, and BIL01 over COMMONT BILLIBT ORDDTAT VENDOR, each after the task library. Each compile's log shows the list it used:
Library list of application BILLING for stage test, after build library AITSK00015: COMMONT BILLIBT ORDDTAT VENDOR
The lists apply to compiles only, including Compile in the File Browser. SQL queries, the agent's SSH commands and interactive sessions keep using the user profile's library list, as with named lists.
Build rules for every application
An all-applications build-rules profile generates rules the way the objects compile. See Build rules for all applications for the page and its settings.
- Each application is analyzed separately, with its own list at the profile's stage, over the library directories it lists. Its dependencies get rules only within its own libraries, so one application's run never writes another application's directories.
- Libraries that no application lists are never analyzed. Vendor, source-only and include libraries on a list are resolved through and get no rules.
- One review and one commit. Every application's rules go into one task, with a report by application. An application that fails gets no rules in it, and the others' rules are kept.
- An application can override the profile's options and its source search library list.
- Stale rules are flagged, never regenerated silently. When an application's list or library directories change, its rules are flagged as stale on the Generate IBM i Build Rules page and in an IBM i Import automation's outcome, with a way to regenerate that application. See Stale rules.
A profile that names one application remains for exceptions, such as another system, a subset of libraries or individual objects.
Switching from named lists
Shops that already compile with named lists on the Build connection, and generate rules with a build-rules profile per application, can keep doing so. Switching to applications is one change in three parts, made back to back:
-
The file. Write
.codermake/config.jsonfrom your current settings:From Becomes Each build-rules profile One application The profile's selected libraries That application's libraries, as library directoriesThe profile's library list That application's productionlistThe Build connection's named list of the same name That application's testlistThen list every other directory that has build targets under the application it belongs to, derive each include path from the production list, and check the file. An agent can do all of this for you.
-
The connection's stage. On the Build connection, choose Repository applications in Library Lists From, and enter
testin Applications Stage. Saving removes the named lists. -
One all-applications profile. Replace the per-application build-rules profiles with one profile that covers All applications at
production. Carry any option or source search library list that one of the old profiles had and the others didn't as that application's override. In each IBM i Import automation, check the new profile under Build Rules Profiles and uncheck the old ones.
:::caution Make these changes back to back Add the file, switch the Build connection and replace the profiles together, with no builds in between. Either side alone fails builds by design: codermake refuses a named list in a repository that defines applications, and a stage in a repository that doesn't. The connection and the profile can be saved before the file is on the branch, and each warns you that the branch doesn't define it yet. :::
An IBM i Import automation that moves to the all-applications profile keeps the object history of the libraries its old profiles covered, so its next run regenerates only what changed. The applications that take over those libraries are recorded as Current (assumed): their rules are assumed to match their definitions at that point, so a later change to their list or libraries is flagged as stale. To record what actually produced their rules, regenerate them once: run the profile from the Generate IBM i Build Rules page, or choose Run Now on the automation.
Derived build order
When one run builds a changed file and a program that uses it, the file has to be built first, or the program compiles against the old file. Rules generated without cross-library dependencies link a program to a file in another library directory only by the file's source, so nothing used to make the file come first: targets were built in library-directory order, and a program in billib was compiled before a changed file in orddta.
codermake now derives that order each time it runs: a target that uses another target's source is built after that target. In the example, the file in orddta is built before the program in billib.
- It applies to every repository, with or without applications.
- It changes the order only, never what is built. A change to the program alone doesn't rebuild the file. A run narrowed to the program builds the file first only when the file is out of date, as with any other prerequisite.
- Nothing is written into
Rules.mk. The order is worked out from the rules present in each run, so a library whose rules haven't been generated yet adds nothing. - Two targets that use each other's source get no derived order between them, and codermake warns, naming both.
Requirements
- codermake 4.8.0 or later in the environment's image. It checks the file by the rules on this page, as CoderFlow does, and follows the derived build order. Rebuild the base image and the environment's image to get it. With an older codermake, the task's log shows an error.
- A Build connection available for Tasks. Library Lists From appears only then.
Limits
- A repository without applications behaves as before. Without an
applicationskey in.codermake/config.json, named lists and the user profile's library list work as they always have. The derived build order is the only change, and it applies to every repository. - Children and reviewers don't build over a project build. With repository applications, children on a project branch and reviewers of its children build over the normal libraries, as when Build Children and Reviewers Over It is off. See Children and reviewers.
- With a Build Directory, CoderFlow can't check the stage. CoderFlow reads
.codermake/config.jsononly at the repository's root, while codermake reads it in the Build Directory. Saving the connection then says the stage couldn't be checked, and project builds need Code Libraries, because CoderFlow can't tell which libraries the build compiles with. Task builds work. - Azure DevOps repositories can't be read for applications yet. Task builds work, because codermake reads the file in the task's checkout. But CoderFlow can't read the file on the server: saving the connection says the stage couldn't be checked, build-rules profiles can't use applications, and project builds fail. GitHub repositories and repositories hosted by CoderFlow work.
- Script deployments get no stage. A deployment profile script that runs codermake in a repository with applications must set
CODERMAKE_STAGEitself, for exampleexport CODERMAKE_STAGE=productionbefore it calls codermake. Without it, codermake refuses to build.