smalltalkpharoseasidepharocloudpharo-6

How do you add dependency to a Pharo image?


After building an application using Seaside I managed to push my Pharo image code to GitHub using iceberg. I was able to clone it into a new Pharo image on a new machine. However, loading the package into the image seems to generate an error requesting some seaside dependencies. I still don't understand the concept of adding a dependency to a Pharo image. Could one explain to me how to go about doing it? I need it for code deployment and collaboration.


Solution

  • I'm sorry, I don't understand completely your question. If you mean how can you define a project (which can have dependencies, etc.), something like you would be doing with, for instance, maven, you need to define a Baseline.

    A baseline is a class (and a package) that you need to define and save with your sources. Take this one as example: https://github.com/estebanlm/logger/blob/master/src/BaselineOfLogger/BaselineOfLogger.class.st

    (this is the smallest example I found, and the project itself is not very interesting).

    I will explain it in parts:

    You have a class named BaselineOfLogger that inherits of BaselineOf and is placed in a package with the same name of the baseline (this is important, for the tools to find it later).

    You define a method tagged with the pragma baseline (pragmas are a little bit like annotations):

    BaselineOfLogger >> baseline: spec [
        <baseline>
    
        spec for: #pharo do: [
            self beacon: spec.
            spec package: 'Logger' ].   
    ]
    

    as you can see this method defines a "spec" for Pharo: - it will load beacon project (we'll see this later) - it declares it will load the package Logger.

    The method beacon: is defined like this:

    BaselineOfLogger >> beacon: spec [
        spec 
            baseline: 'Beacon'
            with: [ spec repository: 'github://pharo-project/pharo-beacon/repository' ]
    ]
    

    and as you can see, it points to another project (and another baseline). Now, since you need Seaside, your Baseline could look something like this:

    BaselineOfMyProject >> baseline: spec [
        <baseline>
    
        spec for: #pharo do: [
            spec 
                baseline: 'Seaside3'
                with: [ 
                    spec repository: 'github://SeasideSt/Seaside:v3.2.4/repository' ]
            spec package: 'MyPackage' ].    
    ]
    

    Finally, in your image, to load you will do something like this:

    Metacello new 
        repository: 'github://yourname/yourprojectname/src';
        baseline: 'MyProject';
        load.
    

    This is more or less like that. But please note than declaring dependencies is a complicated matter (no matter the language you use) and the example I made will cover just the very basics.