简体   繁体   中英

IntelliJ UML diagrams to PNG using Maven plugin

Is it possible to make a Maven plugin to convert the output XML from IntelliJ to PNG in a certain directory in target. Would be nice, because then those diagrams will always be up-to-date after a clean install. It would be nice to use Maven site to publish them and that would make this documentation part of the build / release.

Or if someone would provide the the Java code to convert the XML to PNG (what already is possible in the current UI of IntelliJ by pressing export to file) then I can make the Maven plugin my self.

Example of the output XML file from IntelliJ

<?xml version="1.0" encoding="UTF-8"?>
<Diagram>
  <ID>JAVA</ID>
  <OriginalElement />
  <nodes>
    <node x="0.0" y="980.0">com.example.module.tree.domain.SomeThingTreeConfigurationException</node>
    <node x="578.0" y="628.0">com.example.module.tree.logic.impl.FixedTreeConfigTopic</node>
    <node x="722.0" y="255.0">com.example.module.tree.logic.impl.FixedTreeSomeThingTreeProviderProducer</node>
    <node x="0.0" y="276.0">com.example.module.tree.logic.impl.FixedTreeSomeThingTreeProvider</node>
    <node x="722.0" y="0.0">com.example.module.tree.api.SomeThingTreeProviderProducer</node>
    <node x="743.5" y="114.0">com.example.module.tree.api.ConfigurableSomeThingTreeProviderProducer</node>
    <node x="0.0" y="628.0">com.example.module.tree.domain.SomeThingTreeConfiguration</node>
    <node x="33.0" y="0.0">com.example.module.tree.api.SomeThingTreeProvider</node>
  </nodes>
  <notes />
  <edges>
    <edge source="com.example.module.tree.api.ConfigurableSomeThingTreeProviderProducer" target="com.example.module.tree.api.SomeThingTreeProviderProducer">
      <point x="0.0" y="-45.5" />
      <point x="0.0" y="32.0" />
    </edge>
    <edge source="com.example.module.tree.logic.impl.FixedTreeSomeThingTreeProvider" target="com.example.module.tree.api.SomeThingTreeProvider">
      <point x="0.0" y="-153.5" />
      <point x="0.0" y="113.0" />
    </edge>
    <edge source="com.example.module.tree.logic.impl.FixedTreeSomeThingTreeProviderProducer" target="com.example.module.tree.api.ConfigurableSomeThingTreeProviderProducer">
      <point x="0.0" y="-59.0" />
      <point x="0.0" y="45.5" />
    </edge>
  </edges>
  <settings layout="Hierarchic Group" zoom="1.0" x="257.0" y="253.0" />
  <SelectedNodes>
    <node>com.example.module.tree.logic.impl.FixedTreeConfigTopic</node>
  </SelectedNodes>
  <Categories>
    <Category>Methods</Category>
  </Categories>
  <SCOPE>All</SCOPE>
  <VISIBILITY>private</VISIBILITY>
</Diagram>

I see this question is a couple of years old, but I thought I'd add my alternative Javadoc Doclet to the existing answers for others with the same question, as I haven't found another doclet around that works with Javadoc 9 and newer.

Mine does and you can find it here: https://github.com/talsma-ict/umldoclet

It'd be great if more people could try it out and report feedback.

自己还没有尝试过,但也许您正在寻找https://github.com/gboersma/uml-java-doclet

The approach you suggest would make your build pipeline dependent on your IDE, which I think isn't a good idea. Most developers want to be free to choose their tools.

I did find some Maven plugins that generate UML class diagrams. Hope that helps.

Alternatively you could add a command line tool to your sources (checking it into your version control system) and use the exec-maven-plugin to run it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM