Metacello / metacello

Metacello is a package management system for Smalltalk
MIT License
87 stars 43 forks source link

Spec API: Require different packages/group of a depended baseline for different specified packages #551

Closed LinqLover closed 2 years ago

LinqLover commented 2 years ago

I am specifying the baseline for a project that consists of a few packages, let's call them MyProjectCore and MyProjectTests (the latter requiring the first one). My project depends on another project which consists of two packages again, TheOtherCore and TheOtherTests. I now would like to declare a requirement from MyProjectCore on TheOtherCore, and a second requirement from MyProjectTests on TheOtherTests. However, I don't see a way to specify this because apparently, I can only specify a baseline once with a single #loads:.

Currently, my baseline definition looks like this:

baseline: spec
    <baseline>

    spec for: #common do: [
        "dependencies"
        spec
            baseline: 'TheOther' with:
                [spec
                    repository: 'github://LinqLover/TheOther/packages';
                    loads: #('TheOtherCore' 'TheOtherTests')].

        "packages"
        spec
            package: 'MyProjectCore' with: [
                spec requires: 'TheOther'];
            package: 'MyProjectTests' with: [
                spec requires: 'MyProjectCore']].

The problem with this approach is that even when I only load MyProjectCore into some image, TheOtherTests will be loaded redundantly as well.

What I am seeking for would be something like this:

baseline: spec
    <baseline>

    spec for: #common do: [
        "dependencies"
        spec
            baseline: 'TheOther' named: 'TheOtherCore' with: "pseudo!"
                [spec
                    repository: 'github://LinqLover/TheOther/packages';
                    loads: 'TheOtherCore'];
            baseline: 'TheOther' named: 'TheOtherTests' with: "pseudo!"
                [spec
                    repository: 'github://LinqLover/TheOther/packages';
                    loads: 'TheOtherTests'].

        "packages"
        spec
            package: 'MyProjectCore' with: [
                spec requires: 'TheOtheCore'];
            package: 'MyProjectTests' with: [
                spec requires: #('MyProjectCore' 'TheOtherTests')]].

But there is not yet any solution for this, is it? :-)

dalehenrich commented 2 years ago

Christophe,

If you want to re-use a baseline reference, you can use project:copyFrom:with: where you can create an alias for a project with a different set of package... In fact here is a example from the BaselineOfSeaside3 that does exactly what I think you want:

spec

 baseline: 'Grease'
  with: [
    spec
      loads: #('Grease-Core');
      repository: 'github://SeasideSt/Grease:v1.7.x/repository' ].
    spec
      project: 'Grease Core Tests'
      copyFrom: 'Grease'
      with: [ spec loads: #('Core Tests') ]

Dale

On Sat, Jan 22, 2022 at 5:44 PM Christoph Thiede @.***> wrote:

I am specifying the baseline for a project that consists of a few packages, let's call them MyProjectCore and MyProjectTests (the latter requiring the first one). My project depends on another project which consists of two packages again, TheOtherCore and TheOtherTests. I now would like to declare a requirement from MyProjectCore on TheOtherCore, and a second requirement from MyProjectTests on TheOtherTests. However, I don't see a way to specify this because apparently, I can only specify a baseline once with a single #loads:.

Currently, my baseline definition looks like this:

baseline: spec

spec for: #common do: [ "dependencies" spec baseline: 'TheOther' with: [spec repository: 'github://LinqLover/TheOther/packages'; loads: #('TheOtherCore' 'TheOtherTests')]. "packages" spec package: 'MyProjectCore' with: [ spec requires: 'TheOther']; package: 'MyProjectTests' with: [ spec requires: 'MyProjectCore']]. The problem with this approach is that even when I only load MyProjectCore into some image, TheOtherTests will be loaded redundantly as well. What I am seeking for would be something like this: baseline: spec spec for: #common do: [ "dependencies" spec baseline: 'TheOther' named: 'TheOtherCore' with: "pseudo!" [spec repository: 'github://LinqLover/TheOther/packages'; loads: 'TheOtherCore']; baseline: 'TheOther' named: 'TheOtherTests' with: "pseudo!" [spec repository: 'github://LinqLover/TheOther/packages'; loads: 'TheOtherTests']. "packages" spec package: 'MyProjectCore' with: [ spec requires: 'TheOtheCore']; package: 'MyProjectTests' with: [ spec requires: #('MyProjectCore' 'TheOtherTests')]]. But there is not yet any solution for this, is it? :-) — Reply to this email directly, view it on GitHub , or unsubscribe . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
LinqLover commented 2 years ago

Very nice, it worked, thank you!

Just one additional idea: Referring to your example, I would consider it a little bit more deduplicated if I could also refer to the properties of the original spec, for instance:

   spec
      baseline: 'Grease'
       with: [
         spec
           loads: #('Grease-Core');
           repository: 'github://SeasideSt/Grease:v1.7.x/repository' ].
         spec
           project: 'Grease Core Tests'
           copyFrom: 'Grease'
           with: [ spec loads: spec loads , #('Tests') ]

Currently, this raises a DNU for MetacelloBaselineConstructor>>loads. However, this is only syntactical sugar, so if you decide not to support this, please close this issue. :-)

dalehenrich commented 2 years ago

@LinqLover not a bad idea at all ... however, I'm afraid that the Metacello code base is a bit splintered at this point in time and I have not way of ENSURING that a new feature added to Metacello today would actually make it into all of the platforms that use Metacello will pick up the change and at this point I think it is important that compatibility be preserved ... My efforts these days are aimed at Rowan, which is intended as a "modern" replacement for Metacello ...

LinqLover commented 2 years ago

Alright, thanks for the update. But Rowan is not yet ready for production in @squeak-smalltalk, is it? :)

dalehenrich commented 2 years ago

It's not ready for production in GemStone either :) When it is released in GemStone, I would be willing to help folks port Rowan to their platform ... unlike Metacello which was designed to NOT NEED custom in-image tools (as it uses the browser to create configurations and baselines), Rowan will need custom in-image tools for defining/managing components and load specs ...