Skip to main content
Engineering LibreTexts

8.12: Platform Specific Package

  • Page ID
    45283
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Suppose that we want to have different packages loaded depending on the platform the configuration is loaded in. In the context of our example our Cool Browser we can have a package called CoolBrowser-Platform. There we can define abstract classes, APIs, etc. And then, we can have the following packages: CoolBrowser-PlatformPharo, CoolBrowser-PlatformGemstone, etc.

    Metacello automatically loads the package of the used platform. But to do that, we need to specify platform specific information using the method for:do: as shown in the following example. Here we define that a different package version will be loaded depending on the platform. The platform specific packages will be loaded in addition to the common ones depending on which plateform you are executing the script.

    ConfigurationOfCoolBrowser>>version09: spec
        <version: '0.9' imports: #('0.9-baseline')>
    
        spec for: #common do: [
            ...
            spec
             ...
                package: 'CoolBrowser-AddonsTests' with: 'CoolBrowser-AddonsTests-
         JohnLewis.1' ].
    
        spec for: #gemstone do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformGemstone-
         BobJones.4'.].
        spec for: #pharo do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformPharo-
         JohnLewis.7'.].
    

    Specifying versions is one aspect though you should also specify baseline specific information.

    ConfigurationOfCoolBrowser>>baseline09: spec
        <version: '0.9-baseline'>
        
        spec for: #common do: [
            spec blessing: #baseline.
            spec repository: 'http://www.example.com/CoolBrowser'.
            
            spec
                package: 'CoolBrowser-Core';
                package: 'CoolBrowser-Tests' with: [ spec requires: 'CoolBrowser-Core' ];
                package: 'CoolBrowser-Addons' with: [ spec requires: 'CoolBrowser-Core' ];
                package: 'CoolBrowser-AddonsTests' with: [
                    spec requires: #('CoolBrowser-Addons' 'CoolBrowser-Tests' ) ].
            spec
                group: 'default' with: #('CoolBrowser-Core' 'CoolBrowser-Addons' );
                group: 'Core' with: #('CoolBrowser-Core' 'CoolBrowser-Platform' );
                group: 'Extras' with: #('CoolBrowser-Addon');
                group: 'Tests' with: #('CoolBrowser-Tests' 'CoolBrowser-AddonsTests' );
                group: 'CompleteWithoutTests' with: #('Core', 'Extras' );
                group: 'CompleteWithTests' with: #('CompleteWithoutTests', 'Tests' )].
    
        spec for: #gemstone do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformGemstone'].
        spec for: #pharo do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformPharo'].
    

    Notice that we add the package CoolBrowser-Platform in the Core group. As you can see, we can manage this package as any other and in a uniform way. Thus, we have a lot of flexibility. At runtime, when you load CoolBrowser, Metacello automatically detects in which dialect the load is happening and loads the specific package for that dialect. The for:do: is not only for dialects but also for specific versions of those dialects. For example, we can have:

    ConfigurationOfCoolBrowser>>baseline09: spec
        <version: '0.9-baseline'>
    
        spec for: #common do: [
            spec blessing: #baseline.
            spec repository: 'http://www.example.com/CoolBrowser'.
    
            spec
                package: 'CoolBrowser-Core';
                package: 'CoolBrowser-Tests' with: [ spec requires: 'CoolBrowser-Core' ];
                package: 'CoolBrowser-Addons' with: [ spec requires: 'CoolBrowser-Core' ];
                package: 'CoolBrowser-AddonsTests' with: [
                    spec requires: #('CoolBrowser-Addons' 'CoolBrowser-Tests' ) ].
            spec
                group: 'default' with: #('CoolBrowser-Core' 'CoolBrowser-Addons' );
                group: 'Core' with: #('CoolBrowser-Core' 'CoolBrowser-Platform' );
                group: 'Extras' with: #('CoolBrowser-Addon');
                group: 'Tests' with: #('CoolBrowser-Tests' 'CoolBrowser-AddonsTests' );
                group: 'CompleteWithoutTests' with: #('Core', 'Extras' );
                group: 'CompleteWithTests' with: #('CompleteWithoutTests', 'Tests' )].
    
        spec for: #gemstone do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformGemstone'].
        spec for: #pharo do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformPharo'].
    

    Loading order. Notice that if you are in a system where the platform attributes are (#common #squeakCommon #pharo #'pharo2.x' #'pharo2.0.x') (you can obtain this information doing ConfigurationOf project attributes) and you have specified three sections such as #common, #pharo and #pharo2.0.x, these sections will loaded one after the other.

    ConfigurationOfCoolBrowser>>baseline09: spec
        <version: '0.9-baseline'>
    
        spec for: #common do: [
            spec blessing: #baseline.
            spec repository: 'http://www.example.com/CoolBrowser'.
    
            spec
                package: 'CoolBrowser-Core';
                package: 'CoolBrowser-Tests' with: [ spec requires: 'CoolBrowser-Core' ];
                package: 'CoolBrowser-Addons' with: [ spec requires: 'CoolBrowser-Core' ];
                package: 'CoolBrowser-AddonsTests' with: [
                    spec requires: #('CoolBrowser-Addons' 'CoolBrowser-Tests' ) ].
            spec
                group: 'default' with: #('CoolBrowser-Core' 'CoolBrowser-Addons' );
                group: 'Core' with: #('CoolBrowser-Core' 'CoolBrowser-Platform' );
                group: 'Extras' with: #('CoolBrowser-Addon');
                group: 'Tests' with: #('CoolBrowser-Tests' 'CoolBrowser-AddonsTests' );
                group: 'CompleteWithoutTests' with: #('Core', 'Extras' );
                group: 'CompleteWithTests' with: #('CompleteWithoutTests', 'Tests' )].
    
        spec for: #gemstone do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformGemstone'].
        spec for: #pharo do: [
            spec package: 'CoolBrowser-Platform' with: 'CoolBrowser-PlatformPharo'].
        spec for: #pharo2.0.x do: [
            spec package: 'CoolBrowser-Addons' with: 'CoolBrowser-Core20'].
    

    Finally, note that the method for:do: is not only used to specify a platform specific package, but also for anything that has to do with different dialects. You can put whatever you want from the configuration inside that block. For example, you can define, change and customize groups, packages, repositories, etc, for each dialect dialect and do this:

    ConfigurationOfCoolBrowser>>baseline010: spec
        <version: '0.10-baseline'>
    
        spec for: #common do: [
            spec blessing: #baseline.].
    
        spec for: #pharo do: [
            spec repository: 'http://www.pharo.com/CoolBrowser'.
    
            spec
                ...
            spec
                group: 'default' with: #('CoolBrowser-Core' 'CoolBrowser-Addons' );
                group: 'Core' with: #('CoolBrowser-Core' 'CoolBrowser-Platform' );
                group: 'Extras' with: #('CoolBrowser-Addon');
                group: 'Tests' with: #('CoolBrowser-Tests' 'CoolBrowser-AddonsTests' );
                group: 'CompleteWithoutTests' with: #('Core', 'Extras' );
                group: 'CompleteWithTests' with: #('CompleteWithoutTests', 'Tests' )].
    
        spec for: #gemstone do: [
            spec repository: 'http://www.gemstone.com/CoolBrowser'.
            
            spec
                package: 'CoolBrowser-Core';
                package: 'CoolBrowser-Tests' with: [ spec requires: 'CoolBrowser-Core' ];
            spec
                group: 'default' with: #('CoolBrowser-Core' 'CoolBrowser-Addons' );
                group: 'Core' with: #('CoolBrowser-Core' 'CoolBrowser-Platform' )].
    

    In this example, for Pharo we use a different repository than for Gemstone. However, this is not mandatory, since both can have the same repository and differ in other things, like versions, post and pre code executions, dependencies, etc.

    In addition, the addons and tests are not available for Gemstone, and thus, those packages and groups are not included. As you can see, all that we have been doing inside the for: #common: do: can be done inside another for:do: for a specific dialect.


    This page titled 8.12: Platform Specific Package is shared under a CC BY-SA 3.0 license and was authored, remixed, and/or curated by Alexandre Bergel, Damien Cassou, Stéphane Ducasse, Jannik Laval (Square Bracket Associates) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.