简体   繁体   English

使用 Maven 插件将 IntelliJ UML 图转换为 PNG

[英]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.是否可以制作一个 Maven 插件来将输出的 XML 从 IntelliJ 转换为 target 中某个目录中的 PNG。 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.使用 Maven 站点发布它们会很好,这将使此文档成为构建/发布的一部分。

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.或者,如果有人提供将 XML 转换为 PNG 的 Java 代码(在 IntelliJ 的当前 UI 中可以通过按导出到文件来实现),那么我可以自己制作 Maven 插件。

Example of the output XML file from IntelliJ IntelliJ 的输出 XML 文件示例

<?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.我看到这个问题已经有几年了,但我想我会将我的替代 Javadoc Doclet 添加到其他有相同问题的现有答案中,因为我还没有找到另一个适用于 Javadoc 9 和更新版本的 doclet。

Mine does and you can find it here: https://github.com/talsma-ict/umldoclet我的是,你可以在这里找到它: 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.您建议的方法会使您的构建管道依赖于您的 IDE,我认为这不是一个好主意。 Most developers want to be free to choose their tools.大多数开发人员都希望能够自由选择他们的工具。

I did find some Maven plugins that generate UML class diagrams.我确实找到了一些生成 UML 类图的 Maven 插件。 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.或者,您可以在源代码中添加一个命令行工具(将其检查到您的版本控制系统中)并使用exec-maven-plugin来运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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