Closed linusnorton closed 2 years ago
!include
simply inlines the referenced file, so you essentially have two workspace
definitions in a single file, which is causing the problem you’re seeing. See https://github.com/structurizr/dsl/blob/master/docs/language-reference.md#includes for more.
I see, modifying it to:
b.dsl:
bSystem = softwareSystem "B" {
bContainer = container "B"
}
and a.dsl:
workspace {
model {
!include b.dsl
aSystem = softwareSystem "A" {
aContainer = container "A"
}
aContainer -> bContainer "Uses"
bContainer -> aContainer "Uses"
}
views {
container aSystem "ContainerView" {
include *
autoLayout
}
systemContext aSystem "SystemView" {
include *
autoLayout
}
}
}
Seems to do the trick.
I would say it might be nice to include an example in the docs because it wasn't immediately clear that !include
could be used in any part of the file.
`
Newer versions of Structurizr Lite will actually throw an error if you try to use the workspace
keyword multiple times, so if you're using Lite, you should be able to update. This same feature will be rolled out in the next version of the CLI later this month if you're using that instead.
If I define a container in one file:
and reference it in another
I get an error:
Invalid DSL: The element named B does not exist in the model associated with this view at line 18: include *
I would like to have separate systems in their own file and then be able to use them in downstream systems. Is that possible?