doxygen icon indicating copy to clipboard operation
doxygen copied to clipboard

Using native-image instead of jar

Open fliiiix opened this issue 8 months ago • 9 comments
trafficstars

Is there a way to use a native-image https://github.com/plantuml/plantuml/releases/tag/v1.2025.1-native instead of a jar file.

From digging through the code this does not seem possible. https://github.com/doxygen/doxygen/blob/master/src/plantuml.cpp#L206

fliiiix avatar Feb 28 '25 16:02 fliiiix

It is unclear what you want to achieve / tried. The plantuml jar file is there to convert a uml code to an image and incorporate this into the output (see the commands \startuml, \enduml and \plantumlfile in the documentation). When you want incorporate an image see e.g. the command \image .

All in all:

  • Can you please attach a, small, self contained example (source+configuration file in a, compressed, tar or zip file!) that allows us to reproduce the problem? Please don't add external links as they might not be persistent (also references to GitHub repositories are considered non persistent).
  • Please also specify the full doxygen version used (doxygen -v).

albert-github avatar Feb 28 '25 17:02 albert-github

See attached example.zip. Contains a dockerfile which can be build and run for example like this:

podman build . -t doxygen
podman run -it --volume $(pwd):/ws localhost/doxygen:latest bash

# inside the container
doxygen

This does not work right with the following error message:

Generating PlantUML png Files in html
sh: 1: java: not found
/ws/myclass.h:10: error: Problems running PlantUML. Verify that the command 'java -jar "/usr/bin/plantuml" -h' works from the command line. Exit code: 127

Generating PlantUML eps Files in latex
sh: 1: java: not found
/ws/myclass.h:10: error: Problems running PlantUML. Verify that the command 'java -jar "/usr/bin/plantuml" -h' works from the command line. Exit code: 127

sh: 1: epstopdf: not found
/ws/myclass.h:10: error: Problems running epstopdf. Check your TeX installation! Exit code: 127

the code for it is this:

static void runPlantumlContent(const PlantumlManager::FilesMap &plantumlFiles,
                               const PlantumlManager::ContentMap &plantumlContent,
                               PlantumlManager::OutputFormat format)
{
  /* example : running: java -Djava.awt.headless=true
               -jar "/usr/local/bin/plantuml.jar"
               -o "test_doxygen/DOXYGEN_OUTPUT/html"
               -tpng
               "test_doxygen/DOXYGEN_OUTPUT/html/A.pu"
               -charset UTF-8
               outDir:test_doxygen/DOXYGEN_OUTPUT/html
               test_doxygen/DOXYGEN_OUTPUT/html/A
   */
  int exitCode = 0;
  QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
  QCString plantumlConfigFile = Config_getString(PLANTUML_CFG_FILE);

  QCString pumlExe = "java";
  QCString pumlArgs = "";
  QCString pumlType = "";
  QCString pumlOutDir = "";

  const StringVector &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
  {
    auto it = pumlIncludePathList.begin();
    if (it!=pumlIncludePathList.end())
    {
      pumlArgs += "-Dplantuml.include.path=\"";
      pumlArgs += it->c_str();
      ++it;
    }
    while (it!=pumlIncludePathList.end())
    {
      pumlArgs += Portable::pathListSeparator();
      pumlArgs += it->c_str();
      ++it;
    }
  }
  if (!pumlIncludePathList.empty()) pumlArgs += "\" ";
  pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"\" ";
  if (!plantumlConfigFile.isEmpty())
  {
    pumlArgs += "-config \"";
    pumlArgs += plantumlConfigFile;
    pumlArgs += "\" ";
  }

which assumes that plantuml is jar which is not necessarily true

fliiiix avatar Feb 28 '25 18:02 fliiiix

In the doxytest.zip I only see main.cpp and myclass.h. I'm also missing the used doxygen version and the used settings file (Doxyfile) In the mentioned files there is no reference to plantuml.

Please provide the completed information.

albert-github avatar Feb 28 '25 18:02 albert-github

Ahh yikes uploaded the wrong example. Updated in the previous post. Version is 1.9.4 in debian but i don't think from looking at the code that anything would be different in the latest version.

fliiiix avatar Feb 28 '25 18:02 fliiiix

I now get what you want to accomplish. Since around September 2024 plantuml also provides a number of native images with which it should not be necessary to install java anymore.

  • So this would qualify this problem for an enhancement request.

I downloaded the plantuml-headless-win-amd64-1.2025.1.zip (I don't have a linux system) and extracted the files from it in the local bin directory. I have a small (correct) plantuml file (aa.pu):

@startuml
Alice -> Bob : Hello
@enduml

and ran bin\plantuml-headless.exe -help which showed met the normal (java) help information. When running bin\plantuml-headless.exe -tpng -o aa.png aa.pu (this is the same as when running with doxygen and the jar file) I got a big stack trace with at the top:

java.lang.NoClassDefFoundError: java/util/HashMap
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.jni.functions.JNIFunctions.FindClass(JNIFunctions.java:359)
        at [email protected]/sun.awt.Win32FontManager.populateFontFileNameMap0(Native Method)

So it might be that the, windows, native image is incomplete.

  • Did you try to run something similar on debian?

Edit posted also: https://forum.plantuml.net/19761/running-native-image-on-windows

albert-github avatar Mar 01 '25 10:03 albert-github

So this would qualify this problem for an enhancement request.

I guess that's fair. 👍

And yes i'm running that on linux more specifically on debian and there

plantuml -tpng -o aa.png uml.pu

just works and produces the correct png

And I run that successfully for other things but realized that my doxygen build is now a bit broken because it can not render diagrams anymore because a .jar file is expected.

From a design perspective should this be a a new config flag something like PLANTUML_BIN or should the PLANTUML_JAR_PATH config option be reused and if it is a file and does not end in .jar it should try to just use the provided binary?

fliiiix avatar Mar 01 '25 18:03 fliiiix

I'm not sure how the implementation of the enhancement should look like. To be able to run and test it it would be necessary that I could run it on windows, though I have not had a reaction on my question in the plantuml forum.

albert-github avatar Mar 02 '25 08:03 albert-github

I guess as a workaround you could just create a bat file which forwards the arguments and inside runs something like java -jar /path/to/file.jar $forwarded args$ this would be the same in spirit. (Unfortunately i don't see why the native-image does not work on Windows)

fliiiix avatar Mar 03 '25 13:03 fliiiix

I'm not fond of workarounds. I already made a comment at https://github.com/plantuml/plantuml/issues/1344 and it looks like theer might be some action from that side, which would be far better. At the moment doxygen can still use the normal jar way.

albert-github avatar Mar 03 '25 14:03 albert-github