Aggregation/composition defined outside of package causes package to be displayed incorrectly

0 votes
asked Oct 26, 2016 in bug by dphaynes (120 points)
If you move the first relationship into the package, it renders correctly.

@startuml

Class1 "1" *-- "many" Class2 : contains

package Package1 {

    Class1 "1" *-- "many" Class3 : contains

    class Class1 {
    }
    
    class Class2 {
    }
    
    class Class3 {
    }
}

@enduml
 

I'm using the Eclipse plugin in Mars.2 on Windows 7 x64

Extremely cool bit of work BTW, thanks much! I'm experimenting, trying to see if I can replace Enterprise Architect with it. Not nearly as many features, but a lot easier to track the significant changes to the diagrams.

1 Answer

0 votes
answered Feb 2 by hukameniz (5,510 points)

In PlantUML, also like in Graphviz, the order of definitions is important.

So it's better to define the classes before the edges (links).

This should work fine:

@startuml
package Package1 {
    class Class1 {
    }
    
    class Class2 {
    }
    
    class Class3 {
    }

    Class1 "1" *-- "many" Class3 : contains
}

Class1 "1" *-- "many" Class2 : contains
@enduml
...