Cannot add preprocessing variables from commandline any more

0 votes
asked Dec 11, 2019 in Bug by Sven
I have set of plantuml models that describe architecture of a larger system. I extract sub-diagrams of these models from Makefiles using the commandline syntax in following way:

plantuml -DSUBMODULE model.pu

And in the model.pu:

!ifdef SUBMODULE

<...>

!endif

With 1.2019.07 this does not work anymore, neither does the newest beta help

With verbose I can see:

(0.336 - 31 Mo) 24 Mo - Creating AParentFolderRegular /...
(0.572 - 31 Mo) 27 Mo - [MemGlobal] Setting $class1_detail
(0.574 - 31 Mo) 27 Mo - [MemGlobal] Setting $class_detail
[Log] SUBMODULE _not_ defined

The small example is:

@startuml

!$class1_detail=%false()
!$class2_detail=%false()

!ifdef SUBMODULE
    !log SUBMODULE defined
    !$class1_detail=%true()
!else
    !log SUBMODULE _not_ defined
!endif

hide circle

@enduml

Either the -D from commandline should work, or it should be explicitly removed as it seems to be in correlation with the change in approach to preprocessing.

In the latter case, kind advise is needed - how can commandline generation of specific views from a larger model be achieved without capability to set variable values at the time of invoking plantuml?

1 Answer

0 votes
answered Dec 11, 2019 by plantuml (226,800 points)
Thanks for the feeback.

This issue should be fixed in the very last beta http://beta.plantuml.net/plantuml.jar

Tell us if it's not working for you !
commented Dec 13, 2019 by Sven
Thank you, now it seems to be working properly.

I wonder if some deprecation warnings would be handy - my model is still using !define and !ifdef approach, but I understand that it is going to be obsolete, there could be a way of finding this out after update and instruction for moving to a new pattern on the web.

I understand that right now it is inevitable to have this $ prefix for variables as optional. This has a sideeffect:

plantuml -DSUBMODULE mymodel.pu

!log "SUBMODULE"

!log "SUBMODULE2"

The output is:

[LOG] ""

[LOG] "SUBMODULE2"

Although it's not a showstopper, I would say that it is unexpected behaviour, and one needs to be streetsmart to make logstrings like this actually work:

"Variable SUBMODULE has a value %get_variable_value(SUBMODULE)"
commented Dec 13, 2019 by plantuml (226,800 points)
> I wonder if some deprecation warnings would be handy - my model is still using !define and !ifdef
> approach, but I understand that it is going to be obsolete,
> there could be a way of finding this out after update and instruction for moving to a new pattern on the web.
>
Ok, we might add some -lint option that will print some warning about use of !define / !ifdef

Speaking about this, we will _probably_ never remove the support for !define/!ifdef.
The fact is that the new preprocessor is not a preprocessor anymore.
We have completely redesigned it from zero and it's actually more a script interpreter than a preprocessor now.
But for the sake of simplicify we still refer to it as "preprocessor".

So we "emulate" the old !define/!ifdef behaviour.
Fortunately this emulation does not break the internal consistency/beauty of the internal Java code, so we do not mind keeping it.

> I understand that right now it is inevitable to have this $ prefix for variables as optional.
>
Yes, it will break ascending capability, which have been already impacted by this new "preprocessor".
So we do not want to bother users too much.

> This has a sideeffect:
> (...)
> "Variable SUBMODULE has a value %get_variable_value(SUBMODULE)"
Could you open a new issue about this ?
There might have been several option to fix this, so a new issue would be better.
Thanks!
...