Search code examples
smalltalkpharometacello

Determining loaded group from postLoadDoIt:


Is it possible to determine what group was used to load a particular baseline from postLoadDoIt: in Metacello?

For example:

BaselineOfProject>>baseline: spec
    <baseline>
    ...
    spec group: 'default' with: #(...).
    spec group: 'complete' with: #(...).
    spec postLoadDoIt: #postLoad:spec:.

BaselineOfProject>>postLoad: loader spec: spec
    "spec or loader something something" = 'complete' ifFalse: [ ^ self ].
    do something.

So if the project is then loaded as

Metacello new
    baseline: #Project;
    repository: '...';
    load

the #postLoadDoIt is NOT executed (or rather it is return soon thereafter), but if I do

Metacello new
    baseline: #Project;
    repository: '...';
    load: 'complete'

it will be executed.

So is it possible to determine the group somehow from spec or loader?


Solution

  • Not by default. It is possible to define different groups that result in the same combination of packages being loaded and Metacello itself does not record which groups were actually loaded. If you want to know you can of course override the default behaviour to record.