I'm using asciidoctor-maven-plugin and asciidoctor-diagram to generate PlantUML diagrams (more specifically C4-PlantUML diagrams). When generating those diagrams, output is polluted by these kind of messages
[Log] "dynamic undefined legend colors" requires PlantUML version >= 1.2021.6, therefore only static assigned colors are used
I tracked them down to asciidoctor-diagram embedding - in its source, lo less, a reasonably old version of PlantUML (see their Github source).
Fortunatly, there is in asciidoctor-diagram plantuml converter.rb class some code to use PlantUML provided externally through an environment variable named DIAGRAM_PLANTUML_CLASSPATH
.
But as I use asciidoctor-diagram through asciidoctor-maven-plugin, how can I set that environment variable from my Maven POM without setting it in the maven launch ? Indeed, I want to use a dependency from my pom and maven-dependency-plugin properties goal to have it correct on any machine without configuration.
I've already tried using asciidoctor-maven-plugin configuration attributes
, but it didn't seem to work.
Is there any other way to inject environment variables into asciidoctor-maven-plugin ?
EDIT 1 I've also tried using the properties-maven-plugin to add the environment variable to my maven build this way
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>Set DIAGRAM_PLANTUML_CLASSPATH from PlantUML maven dependency PATH</id>
<phase>process-resources</phase>
<goals>
<goal>set-system-properties</goal>
</goals>
<configuration>
<properties>
<property>
<name>DIAGRAM_PLANTUML_CLASSPATH</name>
<value>${net.sourceforge.plantuml:plantuml:jar}</value>
</property>
</properties>
</configuration>
</execution>
</executions>
</plugin>
But it changed nothing
EDIT 2
So, after some reflection, I had to resolve to use the age-long solution : debugging the culprit code (in this case, asciidoctor-maven-plugin).
In AsciidoctorMojo#execute()
, in a long chain of calls, we initialize a JRuby interpreter (in JRubyAsciidoctor#createRubyRuntime
).
When creating this interpreter, we pass the system environment. This system environment DO NOT include my DIAGRAM_PLANTUML_CLASSPATH
variable, so I guess the properties-maven-plugin does not really set it as environment variable for the whole maven build - or there has been some changes in recent maven versions.
However, this JRubyAsciidoctor#createRubyRuntime
method accepts as input a map of environment variables. Can we manipulate it ? Absolutely not as it is a private method.
And guess what ? DIAGRAM_PLANTUML_CLASSPATH
doesn't appear in the list because it's not an environment variable, but a system property, which is quite different.
So the question is more "how can I create an environment variable ? Or inject an environment variable in my ruby env prior to running my build ?"