different behaviour include paths for !include and !includesub

+2 votes
asked May 13, 2019 in Bug by pluyckx (120 points)

Hi,

I am trying to split my project in multiple files, but I encounter some problems with both, the old preprocessor (plantuml v1.2019.03) and the new one (plantuml v1.2019.06beta22).

I have the following setup:

project/
  + subdir/
  |    + component1.puml
  |    + container.puml
  + app.puml

If you give the file component1.puml the following code:

@startuml
!startsub COMP_CLASS

class CompPuml
!endsub
@enduml

The file container.puml

@startuml
!includesub component.puml!COMP_CLASS
class SubPuml
@enduml

And the file app.puml

@startuml
!include sub/inc.puml
@enduml

Then the stable plantuml version generates following output:

[From sub/sub.puml (line2)]

---------------------------

@startuml

!includesub comp.puml!COMP_CLASS

Cannot include comp.puml

The beta plantuml version results in the following output:

[From sub/sub.puml (line2)]

---------------------------

@startuml

!includesub comp.puml!COMP_CLASS

Sytanx Error?

If I use !include, then the stable plantuml will not trigger an error, while the beta version will generate the same output, but it seems plantuml returns an error code. Because when using the GUI of plantuml, the list shows there was an error, however, the generated png is correct.

When also removing the !startsub and !endsub lines in component.puml, both versions of plantuml work fine.

The issue is that !includesub behaves differently from which directories it tries to include the files. I expect the behaviour like !include, if file1 includes file2, and file2 includes (a part of) file3, the include to file3 in file2 is relative to file2. This seems not the case. I also tried to include relative from the working directory or the root file (app.puml in my example above), but nothing works.

Am I doing something wrong or is this a bug in plantuml?

ps: I made a zip which you can download through wetransfer: https://we.tl/t-dyIFu0ooWM. This zip contains some files which simulates the above issue. includesub.puml is the actual issue I want to report. include.puml is the issue that the beta version generates the correct png, but plantuml reports there is an error. The last version is the version that works like it should.

2 Answers

0 votes
answered May 13, 2019 by plantuml (294,960 points)

The issue is that !includesub behaves differently from which directories it tries to include the files. I expect the behaviour like !include, if file1 includes file2, and file2 includes (a part of) file3, the include to file3 in file2 is relative to file2.

This seems not the case.

You are not anything wrong. This looks like a bug in PlantUML

The !includesub is not widely used and not yet implemented in preprocessorV2.

We are going to investigate and we will post here a message when this will be fixed in preprocessorV2. (I don't think we are going to fix it in the old preprocessor since it will be removed in some future.)

Thanks for the feedback!

commented May 14, 2019 by pluyckx (120 points)
Thank you for the feedback. For now I am using a workaround by splitting the files in more files and just use !include. So it is not a showstopper, but it is nice to know this will work again somewhere in the future. It will improve reusability and readability of some diagrams.

I do not expect you fix it in the old preprocessor. I read about the new one and it has some nice features, so it's better to focus more on the new one :).
0 votes
answered Aug 27, 2019 by mthiele (140 points)
I have a huge issue with that bug also.

Hinders me from having files included by includesub which themselves include files by includesub localized in different directories...

Please urgently fix this bug. Thanks!
commented Aug 27, 2019 by plantuml (294,960 points)
Did you try with last version (1.2019.9) ?

If it's not working with that version, then you should create a simple and short example that shows the issue. This way, we will be able to fix it.

Thanks!
commented Aug 27, 2019 by mthiele (140 points)

Just updated to version 1.2019.9, but it still doesn't work.

Example:
project/
  + foreign/
  |   + domains/
  |       + customer/
  |           + entities/
  |               + customer.puml
  + overviews/
  |   + entities_levels.puml
  + own/
      + domains/
          + contract/
              + entities/
                  + contract.puml

customer.puml:
@startuml
[...]
!startsub DEFINITION
[...]
!endsub
[...]
@enduml

contract.puml (!includesub still works fine here):
@startuml
[...]
!startsub DEFINITION
!includesub ../../../../foreign/domains/customer/entities/customer.puml!DEFINITION
[...]
!endsub
[...]
@enduml

entities_levels.puml (!includesub seems to not work here anymore, as it seems to try to include the customer.puml relatively from this file's path rather than from contract.puml file's path where the !includesub is used):
@startuml
[...]
!includesub ../own/domains/contract/entities/contract.puml!DEFINITION
[...]
!endsub
[...]
@enduml

Error output:
[...]
!includesub ../own/domains/contract/entities/contract.puml!DEFINITION
!includesub ../../../../foreign/domains/customer/entities/customer.puml!DEFINITION

 cannot include ../../../../foreign/domains/customer/entities/customer.puml!DEFINITION

Hope you can fix that by my example. Thanks!

commented Aug 27, 2019 by plantuml (294,960 points)
Ok, that's a good start :-)

Now could you give a simpler example, without such a deep tree structure. I think the bug occurs with one single level of folder.

And instead of [...], use dummy text as "Alice -> Bob : message 42"

A complete example will help the resolution of the bug.

Thanks!
commented Aug 27, 2019 by plantuml (294,960 points)
We have found something.

It's difficult to know if it will solve your issue, but you should try last beta http://beta.plantuml.net/plantuml.jar

For the record, the test case is saved in http://beta.plantuml.net/project.zip

Tell us if it's working for you !
commented Aug 28, 2019 by mthiele (140 points)
This solved the issue. Thanks.

Are you able to tell, when there will be a final release for this?
...