In order to support different use cases like interactive loading during development, unattended loading for a continuous integration build, using a specific version name or getting it from the git repository the applications are saved, etc, the loader (a TonelLoader
) will delegate some actions to, currently, three different strategies, all inheriting from the TonelLoaderStrategy
class, each of them with an "interactive" and an "unattended" subclass.
- Prerequisites strategy
- Version strategy
- Base edition strategy
By "interactive" whe mean involving the GUI, so, it is opening a dialog, a prompt of some sort, etc. While by "unattended" we mean that if there is a decision to be taken, it will be programmed in the strategy without requiring the display of any GUI element.
The loader will instantiate a separate TonelApplicationLoader
(aka application loader) to load each Application
, but the strategies are shared among the all the application loaders in the loader.
When loading an Application
the loader will read it's prerequisites from the vaPrerequisites
metadata in the .package
file, but there could be the case where you need to specify some other prerequisite at load time.
This strategy will display an EtPrerequisiteCollectingPrompter
enabling the user to add/remove prerequisites before loading the application
This strategy uses the prequisites specified in the metadata plus the ones computed by the loader.
"Enable it by evaluating"
aTonelLoader useComputedPrerequisites
The version strategy handles both the versioning, and also the creation of editions prior to versioning.
This will prompt the user to specify a version name for each application using the default version name prompter, leaving the option to not define any, and so only the edition will be created, but without versioning it.
"Enable it by evaluating"
aTonelLoader useInteractiveVersioning
This strategy will create an new edition but won't version it. It is useful when you are developing and want to control manually the versioning and/or don't want to version at all.
"Enable it by evaluating"
aTonelLoader doNotCreateVersions
This strategy will use an specified version name when versioning, if you pass nil
as the version name, it will behave like the TonelLoaderNoVersionStrategy
.
"Enable it by evaluating"
aTonelLoader useSpecifiedVersion: 'DEMO 1.1'
This strategy will read the commit hash, the branch name and the commit date from the HEAD
of the git repository and use it as the commit.
This strategy can be used only if the folder containing the Tonel files is managed by a git repository and it doesn't need git executables or any shared library, since we directly read the files in the .git
repository.
"Enable it by evaluating"
aTonelLoader useGitVersion
By default the version name will be something like e022f87-master (2019-12-30T14:30:00-03:00)
, but you can change the pattern specifing any other String
that can be expanded using macros (expandMacrosWith:with:with:
) where the first argument will be the commit hash string, the second the branch name and the third one the branch name.
"Change the pattern to just the commit hash evaluating"
aTonelLoader versionStrategy versionNamePattern: '<1s>'
"Change the pattern to just the commit hash and branch evaluating"
aTonelLoader versionStrategy versionNamePattern: '<1s> (<2s>)'
The loader won't create a new edition of a class or subapplication if there are no changes between what's loaded and what being loaded from Tonel.
To force the creation of new editions, you can set alwaysCreateEdition
in the version strategy, or directly in the loader.
"Force the creation of editions"
aTonelLoader forceCreationOfEditions
When you're loading an Application
or SubApplication
from Tonel sources into your image, if no edition/version of it is loaded from the ENVY Library, and there is an existing version in it, you'll have to chose which version is used as "base" upon which changes will be applied. This is called a "base edition".
When loading the base edition, the application might need to load its prerequisites from the Library, and for that it will delegate the prerequisites loading to the prerequisites strategy defined in the loader.
This is the default strategy, that will display a list of base editions to choose, and prompt the user to select one from the list.
This will automatically select the latest (newest) edition as the base edition for the App/Subapp being loaded.
"Enable it by evaluating"
aTonelLoader useLatestBaseEditions
Below there is a small sample of "recipes" for the common use cases.
Load applications interactively without creating versions
(TonelLoader readFromPath: (CfsPath named: "..."))
beInteractive; "this is redundant, but serves as example"
doNotCreateVersions;
loadApplicationsForPackagesNamed: #('Package-Core' 'Package-Tests')
Load applications unattended from a git repository
(TonelLoader readFromPath: (CfsPath named: "..."))
beUnattended;
useGitVersion;
loadApplicationsForPackagesNamed: #('Package-Core' 'Package-Tests')
Load applications unattended with a specified version name.
(TonelLoader readFromPath: (CfsPath named: "..."))
beUnattended;
useSpecificVersion: 'vX.Y';
loadApplicationsForPackagesNamed: #('Package-Core' 'Package-Tests')