asciidoctor / asciidoctorj-diagram

AsciidoctorJ Diagram bundles the Asciidoctor Diagram RubyGem (asciidoctor-diagram) so it can be loaded into the JVM using JRuby.
Apache License 2.0
10 stars 6 forks source link

Setting PLANTUML_LIMIT_SIZE from outside #12

Open timur-han opened 3 years ago

timur-han commented 3 years ago

Hi,

Thank you for the contribution.

I rely on https://github.com/confluence-publisher/confluence-publisher to publish the documents. This again uses the version 2.0.2 of this library. It is executed over maven.

Due to having large diagrams, I need to set PLANTUML_LIMIT_SIZE=8192. I tried to set it over the environment variables and as well over mvn install -DPLANTUML_LIMIT_SIZE=8192. Unfortunately, neither of them has helped so far.

Is there a way to set it from outside?

robertpanzer commented 3 years ago

@pepijnve Do you have an idea how to set this?

pepijnve commented 3 years ago

I wasn't aware this limit existed I'm afraid. I would have to read through the PlantUML source code as well to find this out. Maybe an environment variable?

timur-han commented 3 years ago

Hi @pepijnve

Thanks for your reply.

Normally, it is set over an environment variable and described in FAQ:

PlantUML limits image width and height to 4096. There is a environment variable that you can set to override this limit: PLANTUML_LIMIT_SIZE. You have to define this variable before launching PlantUML, something like:

set PLANTUML_LIMIT_SIZE=8192

or

setenv PLANTUML_LIMIT_SIZE 8192

Another way is an option in the command line:

java -DPLANTUML_LIMIT_SIZE=8192 -jar /path/to/plantuml.jar ...

However, it did not have any in this case :(

pepijnve commented 3 years ago

When asciidoctor-diagram is used in combination with JRuby, PlantUML runs in-process. It would expect it to pick up that system variable as well. Perhaps the read of that variable happens in a bit of code that's being bypassed by the diagram glue code. I'm not using the regular CLI entry point. I'll check in the source code.

pepijnve commented 3 years ago

The read happens here https://github.com/plantuml/plantuml/blob/0575e7cf08d4508639a214f97abcac258558dee9/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java#L150 The getenv method first attempts to read a system property and falls back to an environment variable. This should work just fine in combination with JRuby. Asciidoctor running under MRI might not work correctly since PlantUML runs in a subprocess there and I'm not 100% sure if the environment variable will be inherited by the subprocess. The system variable will definitely not get passed on.

pepijnve commented 3 years ago

The next diagram release will let you pass a size-limit block attribute or plantuml-size-limit document attribute to override this setting. That'll be much easier to control reliably than using env or sys variables.