Riduidel / aadarchi

A maven archetype to generate easily projects allowing architecture description using a mix of C4, agile architecture, Asciidoc and PlantUML
https://riduidel.github.io/aadarchi/
Apache License 2.0
39 stars 12 forks source link

Allow plantuml to contain tags and custom styles like backgroundColor #323

Open lhauspie opened 1 year ago

lhauspie commented 1 year ago

My initial need is to distinguish some containers from others by changing their background color.

I added a tag to these containers and define a custom style on this tags:

...
smoothingJob = container "Smoothing batch" "Job to smooth a workload" "Spring Batch" "batch"
splittingJob = container "Splitting batch" "Job to split a workload" "Spring Batch" "batch"
...
views {
    styles {
        element batch {
            shape Ellipse
            background #FF0000
        }
    }
}
...

When I use structurizr-lite, the custom styles are rendered well. But the plantuml that is resulting from the dsl (by using the structurizr-export module) does not contain the custom styles.

As far as I understood, we should be able to add this bloc in views to notice the export to also export tags and styles: https://github.com/structurizr/export/tree/main/src/main/java/com/structurizr/export/plantuml#c4plantumlexporter

c4plantuml.tags: true to generate diagram definitions based upon how the Structurizr diagram renderer creates diagrams using tags and styles, false (default) to generate diagram definitions that use the default C4-PlantUML styling (i.e. blue and grey boxes). Please note that with this property set to true, this exporter does not follow the approach that C4-PlantUML uses for tags and styling. If you would like this behaviour instead of what is provided here, you may want to take a look at https://github.com/cloudflightio/structurizr-export-c4plantuml instead.

So I tried to update the content of my workspace.dsl:

...
smoothingJob = container "Smoothing batch" "Job to smooth a workload" "Spring Batch" "batch"
splittingJob = container "Splitting batch" "Job to split a workload" "Spring Batch" "batch"
...
views {
    styles {
        properties {
            c4plantuml.tags true
        }

        element database {
            shape Ellipse
            background #FF0000
        }
    }
}
...

But it has no effect on the exported plantuml...

The changelog of structurizr-export module says that this feature is released in the version 1.8.0 but I saw (in the parent pom.xml) that aadarchi is using the version 1.7.0 of this module.

Is it possible to upgrade the version of structurizr-export dependency ?

That being said, as the initial need is to export the tags, shapes and colors into the plantuml, it seems that a structurizr-export-C4plantuml module is more suitable according to the documentation (I might missunderstand because not fluent in english).

c4plantuml.tags: true to generate diagram definitions based upon how the Structurizr diagram renderer creates diagrams using tags and styles, false (default) to generate diagram definitions that use the default C4-PlantUML styling (i.e. blue and grey boxes). Please note that with this property set to true, this exporter does not follow the approach that C4-PlantUML uses for tags and styling. If you would like this behaviour instead of what is provided here, you may want to take a look at https://github.com/cloudflightio/structurizr-export-c4plantuml instead.

So I let you decide what is the best approach to provide this feature:

The second option seems to be more suitable for the purpose you try to achieve with aadarchi ?

Thanks in advance.

lhauspie commented 1 year ago

@rbriois might be interested too about this topic 😉

simonbrowndotje commented 1 year ago

The following properties can either be set on individual views, or on the view set to apply to all views

So try this instead:

...
smoothingJob = container "Smoothing batch" "Job to smooth a workload" "Spring Batch" "batch"
splittingJob = container "Splitting batch" "Job to split a workload" "Spring Batch" "batch"
...
views {
    properties {
        c4plantuml.tags true
    }

    styles {
        element database {
            shape Ellipse
            background #FF0000
        }
    }
}
...
lhauspie commented 1 year ago

Sorry but, at almost 1:00AM I was a bit tired and miss-pasted the properties part in the original issue.

I retried to generate plantuml with tags by adding the properties part you provided @simonbrowndotje but it doesn't include the tags in the result plantuml.

I think the issue still valid. Sorry for the miss-paste.

rbriois commented 1 year ago

I've made a few tests on my side.

Adding the "c4plantuml.tags true" properties generate the tags in the C4 plantuml generated files but still no styles elements in the generated site.

I've compiled a snapshot of aadarchi upgrading structurizr-export to 1.8.0 and test it on my project and i've now styles elements in the generated site.

I've also try to upgrade structurizr-export to 1.10.1 but i've some compilations errors and i didn't have time to go further.