Loading and managing code configurations with Metacello
Metacello is the code configuration management engine for Pharo. It's like NPM for JavaScript or Maven for Java. It essentially has two abilities: (1) define what packages a project consists of in a so called Metacello baseline, and (2) offer a way to load a given baseline from a remote repository.
Quick start
Consider the following script:
Metacello new baseline: 'GToolkit4P3'; repository: 'github://feenkcom/gt4p3'; load.
Executing the script will load the GTooklit4P3
project from https://github.com/feenkcom/gt4p3. This will load the package GToolkit4P3
and the baseline called BaselineOfP3ForGToolkit
. Go ahead and try. And then browse BaselineOfGToolkit4P3
.
The anatomy of a Metacello baseline
A baseline is defined in plain Pharo code through a fluent API.
Consider BaselineOfDeepTraverser
. It is a subclass of BaselineOf
defines a BaselineOfDeepTraverser>>#baseline:
method that is annotated with a <baseline>
pragma. The method defines a dependency to BaselineOfGToolkitExamplesEngine
and it specifies that there are several package in the project, such as DeepTraverser
.
Simple package definition
A contained package is defined like this:
![](gt-figures/1428.png)
Defining a package with load ordering
Sometimes, we want to specify that a package is to be loaded after another package. For example, DeepTraverser-MemoryTraversal
depends on DeepTraverser
, so we want it loaded afterwards. This is achieved with:
![](gt-figures/1429.png)
Defining a baseline dependency
A baseline dependency is defined similarly:
![](gt-figures/1430.png)
Visualizing baseline and package dependencies
Evaluating the dependencies between packages and projects is easier when seen through a visualization. You can see it in Coder when browsing a baseline. For example, for the baseline of BaselineOfDeepTraverser
we can see this view showing how packages depend on each other and on external projects:
![](gt-figures/1431.png)