Coder Social home page Coder Social logo

leluque / java2uml Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 0.0 119 KB

A metaprogramming-based (reflection and instrumentation) library to generate UML class and sequence diagrams from Java code.

License: GNU General Public License v3.0

Java 100.00%
class-diagram java plantuml sequence-diagram uml yuml

java2uml's Introduction

Java2UML

Overview

Java2UML is a library designed to generate UML class and sequence diagrams from Java classes using instrumentation, reflection, and class loading techniques. This project simplifies the process of visualizing the structure and relationships of classes in a Java project, making it useful for documentation and analysis purposes.

It currently transforms Java classes into yUML and PlantUML class diagrams.

How it works

Given a set of packages and exclusion rules, Java2UML will recursively search for all classes in those packages and generate the diagram textual representation. This representation can then be used to generate a diagram.

Getting Started

Prerequisites

  • Java 17 or higher
  • A Java IDE (e.g., IntelliJ IDEA, Eclipse)

Installation

  1. Clone the repository.
  2. Import the project into your Java IDE.
  3. Build and run the project.

Usage

YUML Class diagram

To generate an YUML class diagram, simply pass a set of packages and exclusion rules you wish.

// Example code using the yUML facade.
YUML yUML=new YUML(); // Facade
yUML.addPackages("br.com.luque.java2uml.example.virtualdrive.domain","com.anotherpackage");
yUML.addClasses("java.lang.String","java.util.ArrayList");
yUML.ignoreClasses("br.com.luque.java2uml.example.virtualdrive.domain.FileSystemItem");
yUML.ignorePackages("br.com.luque.java2uml.example.virtualdrive.dto");
String diagramText=YUML.generateClassDiagram();
    
// You can avoid generating accessor methods creating an instance of YUML object using:
YUML yUML=new YUML().doNotGenerateAccessors();

PlantUML class diagram

To generate a PlantUML class diagram, simply pass a set of packages and exclusion rules you wish.

// Example code using the PlantUML facade.
String diagramText=PlantUML.generateClassDiagram("br.com.luque.java2uml.example.virtualdrive.domain","com.anotherpackage");

// You can also use exclusion rules.
PlantUML plantUML=new PlantUML(); // Facade
plantUML.addPackages("br.com.luque.java2uml.example.virtualdrive.domain","com.anotherpackage");
plantUML.addClasses("java.lang.String","java.util.ArrayList");
plantUML.ignoreClasses("br.com.luque.java2uml.example.virtualdrive.domain.FileSystemItem");
plantUML.ignorePackages("br.com.luque.java2uml.example.virtualdrive.dto");
String diagramText=plantUML.generateClassDiagram();
    
// You can avoid generating accessor methods creating an instance of PlantUML object using:
PlantUML plantUML=new PlantUML().doNotGenerateAccessors();

PlantUML sequence diagram

Enter the project folder, replace the path-to-java2uml-1.0.0.jar with the path to the jar file and br.com.luque.Main by the project main class and run the following command:

java -javaagent:"path-to-java2uml-1.0.0.jar=br.com.luque" br.com.luque.Main

Room for improvement

  • Add unit tests.
  • Add support for other diagram types (e.g., object diagrams).
  • Generate diagram images directly from the tool.
  • Support execution as maven plugin to generate diagrams during build.

java2uml's People

Contributors

leluque avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

java2uml's Issues

Could not find or load main class br.com.luque.Main when trying to get the sequence diagram

Describe the bug
Thanks for this nice project! I am trying to get the sequence diagram from this tool, however when I tried the command inside README.md, I got the error below:

root@ASUS142023SKYG:~/tools/java2uml/target/classes# java -javaagent:"/root/tools/java2uml/target/java2uml-1.0.0.jar=br.com.luque" br.com.luque.Main
Error: Could not find or load main class br.com.luque.Main
Caused by: java.lang.ClassNotFoundException: br.com.luque.Main
##########
PlantUML sequence diagram:
@startuml
 actor Actor as actor

@enduml

If this is due to the class br.com.luque.Main is missing, I am wondering that which class can be used as the parameter?

Thanks for your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.