esteinberg / plantuml4idea

Intellij IDEA plugin for PlantUML
Apache License 2.0
629 stars 114 forks source link

Ability to specify Java command-line arguments such as 'RELATIVE_INCLUDE' #336

Open hannotify opened 2 years ago

hannotify commented 2 years ago

Hi! First of all: thank you for this amazing IntelliJ plugin. My team uses it currently to create C4 architecture diagrams using PlantUML.

Now I cloned the C4-PlantUML repository and want to use its files locally because of a company proxy. When creating a component diagram I include the local copy of C4_Component.puml, for example. But that file includes the C4_Container.puml from the internet by default. If I want to use a local copy, I have to set the RELATIVE_INCLUDE command-line argument. Is there a way to achieve this with the plugin?

I have noticed there is a settings field for PLANTUML_LIMIT_SIZE; we could perhaps generalize this and allow custom command-line arguments instead? I would be more than happy to contribute to that.

TL;DR: Can we specify Java command-line arguments such as RELATIVE_INCLUDE in the plugin? Or would you accept contributions to achieve this?

krasa commented 2 years ago

It can be done like this: image

Perhaps a specialized variable table would be better.

gebezs commented 2 years ago

I tried what @krasa said in the previous comment but unfortunately it doesn't work for the PLANTUML_SECURITY_PROFILE (https://plantuml.com/security). It tried it with and without the $.

%set_variable_value("PLANTUML_SECURITY_PROFILE", "UNSECURE")
%set_variable_value("$PLANTUML_SECURITY_PROFILE", "UNSECURE")

It think it is normal that this isn't working as it isn't a variable. Rather a security directive which shouldn't be specified as part of any diagram. Maybe a dedicated dropdown for the PLANTUML_SECURITY_PROFILE would be a better option in the long term. However it would be great to allow the specification of java system properties as it could be useful in the future.

krasa commented 2 years ago

Modifying IDE's VM options should work. It is initialized once per process/classloader. A dropbox could maybe be added.

gebezs commented 2 years ago

Modifying the IDE's VM options sounds overkill. I'm not familiar how Idea's plugin system works but after a quick search I found this: https://github.com/esteinberg/plantuml4idea/blob/master/adapter/src/org/plantuml/idea/adapter/Utils.java#L93

Am I right to assume that

I couldn't find the test for that. Can you please point me to the right direction?

krasa commented 2 years ago

Yes, Utils.java could handle PLANTUML_SECURITY_PROFILE as well. Until then, IDE's VM options is the way to do it.

There is no test :-)