asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
445 stars 109 forks source link

Nested boxes not getting generated with PlantUML in v2.2.10 (asciidoctorj-diagram) #429

Closed PascalDutch closed 1 year ago

PascalDutch commented 1 year ago

We have some issues building our documentation using the latest release of asciidoctorj-diagram.

We get an error from PlantUML that nested boxes are not supported. This is supported by PlantUML for sometime now, so I tried some different asciidoctorj-diagram versions and the problem only appears when using the latest version 2.2.10, 2.2.9 works fine. I downloaded the PlantUML version used in this asciidoctorj-diagram version (1.2023.5, found here) and that generates the diagram just fine.

Error:

box "SomeText" #APPLICATION
  participant Participant
  box "SomeBox" #LightYellow   
^^^^^                                         
 Box cannot be nested                         

[error] asciidoctor: ERROR: diagram/subdir/file.puml: line 0: Failed to generate image: PlantUML image generation failed: [From <input> (line 16) ]     

AsciiDoc versions:

<asciidoctor-maven-plugin.version>2.2.2</asciidoctor-maven-plugin.version>
<asciidoctorj-diagram.version>2.2.10</asciidoctorj-diagram.version>
<asciidoctorj-pdf.version>2.3.3</asciidoctorj-pdf.version>

I can't put the complete PlantUML diagrams here since they contain classified information.

I initially created an issue at asciidoctorj-diagram, but was sent here.

pepijnve commented 1 year ago

That error is being produced by PlantUML itself. I'll try to figure out where the difference is coming from.

I did give this a quick try already and it seems that, while I'm not getting an error, the boxes aren't really nested either.

image
PascalDutch commented 1 year ago

That error is being produced by PlantUML itself. I'll try to figure out where the difference is coming from.

I did give this a quick try already and it seems that, while I'm not getting an error, the boxes aren't really nested either. image

I believe you need to use the teoz (!pragma teoz true) engine for it to work.

Edit: just tested, without teoz engine the boxes won't be nested.

pepijnve commented 1 year ago

I've added a unit test for this particular case. Seems to run fine, so I'm not entirely sure what's going on.

pepijnve commented 1 year ago

Looking at https://github.com/search?q=org%3Aplantuml%20cannot%20be%20nested&type=code it seems there's a difference between the various variants of PlantUML. That line gets printed in the MIT variant. In the others it's commented out. Perhaps asciidoctorj-diagram is packaging the MIT build? The version that's included in the gem wrapper is the Apache licensed version.

pepijnve commented 1 year ago

I tried a couple of combinations of the various jars. I can't seem to get the error you're seeing. It kind of sounds like, for whatever reason, some different version of PlantUML is being picked up than the one that's bundled.

PascalDutch commented 1 year ago

I isolated it in a separate project (one adoc file and one puml) with the same version as used above and that seems to be running fine. I think the error is on our side then. I agree that for some reason a different PlanUML version is used. Will investigate what the issue (probably next week). Thanks for the assistance though!

pepijnve commented 1 year ago

You could try figuring out which one it is using some PlantUML meta stuff.

If the bundled version is being used

@startuml
license
@enduml

should generate an image containing the ASLv2 license.

@startuml
participant "%version()"
@enduml

should show 1.2023.5

pepijnve commented 1 year ago

One possibility might be that some maven plugin in your project is placing a version of PlantUML on the classpath at build time. asciidoctor-diagram will add PlantUML to the classpath itself, but if it's already the already loaded version may take precedence. I might be able to guard against this by using a dedicated classloader when running under JRuby.

PascalDutch commented 1 year ago

Hmm weird. It shows 1.2019.12 when I run it in the project and 1.2023.5 (expected) in the test project.

pepijnve commented 1 year ago

Well that at least explain a where the error is coming from. There's no code in place yet that could help debug this. The best suggestion I can give you is to somehow print the classpath from Maven to see if there's a rogue PlantUML in there somewhere. I haven't used Maven in ages so I cant really give you advice about how to do this.

PascalDutch commented 1 year ago

After some searching we found that some (inhouse made) plugin in some top level parent pom imported asciidoctorj-diagram 2.2.1. We now overwrite the dependency for that plugin and everything works fine now. Thanks for the help!