Removed files that came from forked repo and not needed in this one.
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 31 Dec 2017 01:28:38 +0000 (03:28 +0200)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Sun, 31 Dec 2017 01:28:38 +0000 (03:28 +0200)
Moved commandline Main to commandline dedicated package.

README.md [deleted file]
javainspect.iml
myproject.dot [deleted file]
myproject.png [deleted file]
myproject.svg [deleted file]
pom.xml
src/main/java/eu/svjatoslav/inspector/java/Main.java [deleted file]
src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java [new file with mode: 0644]
src/main/java/eu/svjatoslav/inspector/java/commandline/package-info.java [new file with mode: 0644]

diff --git a/README.md b/README.md
deleted file mode 100644 (file)
index 5ffec69..0000000
--- a/README.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# JavaInspect
-
-Visualize java class relationships as Graphviz.
-
-Forked from the original work from [Svjatoslav Agejenko](http://www.svjatoslav.eu/).
-This repository only provides minor improvements.
-
-Original [git repository](http://www2.svjatoslav.eu/repositories/javainspect.git)
-
-Original [documentation](http://www2.svjatoslav.eu/gitbrowse/javainspect/doc/index.html)
-
-Minor enhancements:
-
-- Provides java main to run as CLI tool.
-- Produces single executable with dependencies.
-- Default to render SVG.
-- Default to output to `user.dir` (i.e. working directory).
-
-### Building
-
-1. Install [Maven](http://maven.apache.org/).
-2. Package JAR:
-
-    `mvn clean package`
-
-### Running
-
-1. You will need to add the classes would like to visualize to your classpath.
-2. Provide a package glob pattern to identify the classes you want to visualize.
-3. Name your output.
-
-```bash
-java \
-  -cp .:./example/target/myproject-0.0.jar:./target/javainspect-1.6-SNAPSHOT.jar \
-  eu.svjatoslav.inspector.java.methods.Main \
-  ./example/src/main/java/ com.myproject.* myproject
-```
-
-Here we want to visualize _com.myproject.*_ classes found in
-*./example/src/main/java/*. The resulting *dot* and *svg*
-file will be prefixed with *myproject*.
-
-### Output example
-
-![MyProject output](https://github.com/abargnesi/javainspect/raw/master/myproject.png)
-
-The [dot](https://github.com/abargnesi/javainspect/raw/master/myproject.dot) file is also saved.
index 854d268..4edf0f0 100644 (file)
@@ -1,13 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
   <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
-    <output url="file://$MODULE_DIR$/../../target/classes" />
-    <output-test url="file://$MODULE_DIR$/../../target/test-classes" />
-    <content url="file://$MODULE_DIR$/../..">
-      <sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/../../doc/example" isTestSource="false" />
-      <excludeFolder url="file://$MODULE_DIR$/../../target" />
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
diff --git a/myproject.dot b/myproject.dot
deleted file mode 100644 (file)
index 068b68c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-digraph Java {
-graph [rankdir=LR, overlap = false, concentrate=true];
-
-// Class: com.myproject.NumberTranslator
-    class_com_myproject_NumberTranslator[label=<<TABLE  BORDER="1" CELLBORDER="1" CELLSPACING="0">
-
-    // class descriptor header
-    <TR><TD colspan="2" PORT="f0"><FONT POINT-SIZE="8.0" >com.myproject</FONT><br/><FONT POINT-SIZE="25.0"><B>NumberTranslator</B></FONT></TD></TR>
-
-    // methods:
-        // translate
-        <TR><td ALIGN="right"><FONT POINT-SIZE="8.0">String</FONT></td><TD PORT="translate" ALIGN="left"><FONT COLOR ="red" POINT-SIZE="11.0">translate</FONT></TD></TR>
-    </TABLE>>, shape="none"];
-
-    // method references to other classes
-
-    // interfaces implemented by class: com.myproject.NumberTranslator
-    class_com_myproject_Behavior -> class_com_myproject_NumberTranslator[style="dotted", color="antiquewhite4", penwidth=10, dir="forward"];
-
-// Class: com.myproject.Behavior
-    class_com_myproject_Behavior[label=<<TABLE bgcolor="darkslategray1" BORDER="1" CELLBORDER="1" CELLSPACING="0">
-
-    // class descriptor header
-    <TR><TD colspan="2" PORT="f0"><FONT POINT-SIZE="8.0" >com.myproject</FONT><br/><FONT POINT-SIZE="25.0"><B>Behavior</B></FONT></TD></TR>
-
-    // methods:
-        // serialize
-        <TR><td ALIGN="right"><FONT POINT-SIZE="8.0">String</FONT></td><TD PORT="serialize" ALIGN="left"><FONT COLOR ="red" POINT-SIZE="11.0">serialize</FONT></TD></TR>
-        // translate
-        <TR><td ALIGN="right"><FONT POINT-SIZE="8.0">String</FONT></td><TD PORT="translate" ALIGN="left"><FONT COLOR ="red" POINT-SIZE="11.0">translate</FONT></TD></TR>
-    </TABLE>>, shape="none"];
-
-    // method references to other classes
-}
diff --git a/myproject.png b/myproject.png
deleted file mode 100644 (file)
index 268779f..0000000
Binary files a/myproject.png and /dev/null differ
diff --git a/myproject.svg b/myproject.svg
deleted file mode 100644 (file)
index afec2ba..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
- "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<!-- Generated by graphviz version 2.38.0 (20140413.2041)
- -->
-<!-- Title: Java Pages: 1 -->
-<svg width="473pt" height="93pt"
- viewBox="0.00 0.00 473.00 93.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 89)">
-<title>Java</title>
-<polygon fill="white" stroke="none" points="-4,4 -4,-89 469,-89 469,4 -4,4"/>
-<!-- class_com_myproject_NumberTranslator -->
-<g id="node1" class="node"><title>class_com_myproject_NumberTranslator</title>
-<polygon fill="none" stroke="black" points="193.5,-31.5 193.5,-70.5 456.5,-70.5 456.5,-31.5 193.5,-31.5"/>
-<text text-anchor="start" x="294" y="-62.1" font-family="Times,serif" font-size="8.00">com.myproject</text>
-<text text-anchor="start" x="196.5" y="-40.5" font-family="Times,serif" font-weight="bold" font-size="25.00">NumberTranslator</text>
-<polygon fill="none" stroke="black" points="193.5,-13.5 193.5,-31.5 312.5,-31.5 312.5,-13.5 193.5,-13.5"/>
-<text text-anchor="start" x="282.5" y="-20.6" font-family="Times,serif" font-size="8.00">String</text>
-<polygon fill="none" stroke="black" points="312.5,-13.5 312.5,-31.5 456.5,-31.5 456.5,-13.5 312.5,-13.5"/>
-<text text-anchor="start" x="315.5" y="-19.7" font-family="Times,serif" font-size="11.00" fill="red">translate</text>
-<polygon fill="none" stroke="black" points="192,-13 192,-72 457,-72 457,-13 192,-13"/>
-</g>
-<!-- class_com_myproject_Behavior -->
-<g id="node2" class="node"><title>class_com_myproject_Behavior</title>
-<polygon fill="#97ffff" stroke="none" points="8,-4 8,-81 140,-81 140,-4 8,-4"/>
-<polygon fill="none" stroke="black" points="9,-40.5 9,-79.5 139,-79.5 139,-40.5 9,-40.5"/>
-<text text-anchor="start" x="43" y="-71.1" font-family="Times,serif" font-size="8.00">com.myproject</text>
-<text text-anchor="start" x="12" y="-49.5" font-family="Times,serif" font-weight="bold" font-size="25.00">Behavior</text>
-<polygon fill="none" stroke="black" points="9,-22.5 9,-40.5 61,-40.5 61,-22.5 9,-22.5"/>
-<text text-anchor="start" x="31" y="-29.6" font-family="Times,serif" font-size="8.00">String</text>
-<polygon fill="none" stroke="black" points="61,-22.5 61,-40.5 139,-40.5 139,-22.5 61,-22.5"/>
-<text text-anchor="start" x="64" y="-28.7" font-family="Times,serif" font-size="11.00" fill="red">serialize</text>
-<polygon fill="none" stroke="black" points="9,-4.5 9,-22.5 61,-22.5 61,-4.5 9,-4.5"/>
-<text text-anchor="start" x="31" y="-11.6" font-family="Times,serif" font-size="8.00">String</text>
-<polygon fill="none" stroke="black" points="61,-4.5 61,-22.5 139,-22.5 139,-4.5 61,-4.5"/>
-<text text-anchor="start" x="64" y="-10.7" font-family="Times,serif" font-size="11.00" fill="red">translate</text>
-<polygon fill="none" stroke="black" points="8,-4 8,-81 140,-81 140,-4 8,-4"/>
-</g>
-<!-- class_com_myproject_Behavior&#45;&gt;class_com_myproject_NumberTranslator -->
-<g id="edge1" class="edge"><title>class_com_myproject_Behavior&#45;&gt;class_com_myproject_NumberTranslator</title>
-<path fill="none" stroke="#8b8378" stroke-width="10" stroke-dasharray="1,5" d="M148.214,-42.5C156.343,-42.5 164.825,-42.5 173.482,-42.5"/>
-<polygon fill="#8b8378" stroke="#8b8378" stroke-width="10" points="173.713,-51.2501 183.713,-42.5 173.713,-33.7501 173.713,-51.2501"/>
-</g>
-</g>
-</svg>
diff --git a/pom.xml b/pom.xml
index 0a9bf25..755138e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
                         <configuration>
                             <transformers>
                                 <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                                    <mainClass>eu.svjatoslav.inspector.java.Main</mainClass>
+                                    <mainClass>eu.svjatoslav.inspector.java.commandline.Main</mainClass>
                                 </transformer>
                             </transformers>
                         </configuration>
diff --git a/src/main/java/eu/svjatoslav/inspector/java/Main.java b/src/main/java/eu/svjatoslav/inspector/java/Main.java
deleted file mode 100644 (file)
index 9b706d3..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-package eu.svjatoslav.inspector.java;
-
-import eu.svjatoslav.inspector.java.commandline.CommandlineConfiguration;
-import eu.svjatoslav.inspector.java.structure.ClassGraph;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-
-import static java.io.File.separator;
-import static java.lang.System.getProperty;
-
-/**
- * This class acts as a commandline interface for JavaInspect.
- */
-public class Main {
-    public static void main(String[] args) throws IOException, ClassNotFoundException {
-        CommandlineConfiguration configuration = new CommandlineConfiguration(args);
-        if (!configuration.configurationOk)
-            System.exit(1);
-            
-        getClassGraph(configuration).generateGraph(configuration.graphName.getValue());
-
-        if (configuration.isDebug())
-            System.out.println("Graph ready.");
-    }
-
-    private static ClassGraph getClassGraph(CommandlineConfiguration configuration) throws IOException, ClassNotFoundException {
-        List<File> jarFiles = configuration.jarFiles.getValue();
-
-        URLClassLoader classLoader = new URLClassLoader(
-                getFileUrls(jarFiles),
-                configuration.getClass().getClassLoader());
-
-        ClassGraph classGraph = new ClassGraph();
-
-        classGraph.setTargetDirectory(getTargetDirectory(configuration));
-
-        if (configuration.targetImageType.isSpecified())
-            classGraph.setTargetImageType(configuration.targetImageType.getValue());
-
-        classGraph.setKeepDotFile(configuration.keepDotFile.getValue());
-
-        for (File jarFile : jarFiles)
-            addJarToGraph(jarFile, classLoader, classGraph, configuration);
-
-        configuration.blacklistGlob.getValue().forEach(classGraph::blacklistClassGlob);
-        configuration.whitelistGlob.getValue().forEach(classGraph::whitelistClassGlob);
-
-        if (configuration.hideOrphanedClasses.getValue())
-            classGraph.hideOrphanedClasses();
-
-        return classGraph;
-    }
-
-    private static File getTargetDirectory(CommandlineConfiguration configuration) {
-        if (configuration.targetDirectory.isSpecified())
-            return configuration.targetDirectory.getValue();
-
-        // default to current directory
-        return new File(getProperty("user.dir") + separator);
-    }
-
-    private static URL[] getFileUrls(List<File> jarFiles) {
-        List<URL> urls = new ArrayList<>();
-        jarFiles.forEach((File file) -> {
-            try {
-                urls.add(file.toURI().toURL());
-            } catch (MalformedURLException e) {
-                throw new RuntimeException(e);
-            }
-        });
-
-        return urls.toArray(new URL[urls.size()]);
-    }
-
-    private static void addJarToGraph(
-            File jarFile, URLClassLoader classLoader, ClassGraph classGraph, CommandlineConfiguration configuration)
-            throws IOException, ClassNotFoundException {
-
-        for (String className : getClassNamesFromJar(jarFile)) {
-            if (configuration.isDebug())
-                System.out.println("Adding class to graph: " + className);
-
-            classGraph.add(loadClassByName(classLoader, className));
-        }
-    }
-
-    private static Class loadClassByName(URLClassLoader classLoader, String className) throws ClassNotFoundException {
-        return Class.forName(className, true, classLoader);
-    }
-
-    public static List<String> getClassNamesFromJar(File jarFile) throws IOException {
-        List<String> result = new ArrayList<>();
-        try (
-                JarInputStream jarInputStream = new JarInputStream(new FileInputStream(jarFile))
-        ) {
-            while (true) {
-                JarEntry jarEntry = jarInputStream.getNextJarEntry();
-                if (jarEntry == null)
-                    break;
-
-                if (isClassFile(jarEntry))
-                    result.add(getClassNameFromFileName(jarEntry));
-            }
-
-            return result;
-        }
-    }
-
-    private static boolean isClassFile(JarEntry jarEntry) {
-        return jarEntry.getName().endsWith(".class");
-    }
-
-    private static String getClassNameFromFileName(JarEntry jarEntry) {
-        String result = jarEntry.getName().replaceAll("/", "\\.");
-        return result.substring(0, result.lastIndexOf('.'));
-    }
-}
diff --git a/src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java b/src/main/java/eu/svjatoslav/inspector/java/commandline/Main.java
new file mode 100644 (file)
index 0000000..8fcf5f6
--- /dev/null
@@ -0,0 +1,126 @@
+package eu.svjatoslav.inspector.java.commandline;
+
+import eu.svjatoslav.inspector.java.commandline.CommandlineConfiguration;
+import eu.svjatoslav.inspector.java.structure.ClassGraph;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+
+import static java.io.File.separator;
+import static java.lang.System.getProperty;
+
+/**
+ * This class acts as a commandline interface for JavaInspect.
+ */
+public class Main {
+    public static void main(String[] args) throws IOException, ClassNotFoundException {
+        CommandlineConfiguration configuration = new CommandlineConfiguration(args);
+        if (!configuration.configurationOk)
+            System.exit(1);
+            
+        getClassGraph(configuration).generateGraph(configuration.graphName.getValue());
+
+        if (configuration.isDebug())
+            System.out.println("Graph ready.");
+    }
+
+    private static ClassGraph getClassGraph(CommandlineConfiguration configuration) throws IOException, ClassNotFoundException {
+        List<File> jarFiles = configuration.jarFiles.getValue();
+
+        URLClassLoader classLoader = new URLClassLoader(
+                getFileUrls(jarFiles),
+                configuration.getClass().getClassLoader());
+
+        ClassGraph classGraph = new ClassGraph();
+
+        classGraph.setTargetDirectory(getTargetDirectory(configuration));
+
+        if (configuration.targetImageType.isSpecified())
+            classGraph.setTargetImageType(configuration.targetImageType.getValue());
+
+        classGraph.setKeepDotFile(configuration.keepDotFile.getValue());
+
+        for (File jarFile : jarFiles)
+            addJarToGraph(jarFile, classLoader, classGraph, configuration);
+
+        configuration.blacklistGlob.getValue().forEach(classGraph::blacklistClassGlob);
+        configuration.whitelistGlob.getValue().forEach(classGraph::whitelistClassGlob);
+
+        if (configuration.hideOrphanedClasses.getValue())
+            classGraph.hideOrphanedClasses();
+
+        return classGraph;
+    }
+
+    private static File getTargetDirectory(CommandlineConfiguration configuration) {
+        if (configuration.targetDirectory.isSpecified())
+            return configuration.targetDirectory.getValue();
+
+        // default to current directory
+        return new File(getProperty("user.dir") + separator);
+    }
+
+    private static URL[] getFileUrls(List<File> jarFiles) {
+        List<URL> urls = new ArrayList<>();
+        jarFiles.forEach((File file) -> {
+            try {
+                urls.add(file.toURI().toURL());
+            } catch (MalformedURLException e) {
+                throw new RuntimeException(e);
+            }
+        });
+
+        return urls.toArray(new URL[urls.size()]);
+    }
+
+    private static void addJarToGraph(
+            File jarFile, URLClassLoader classLoader, ClassGraph classGraph, CommandlineConfiguration configuration)
+            throws IOException, ClassNotFoundException {
+
+        for (String className : getClassNamesFromJar(jarFile)) {
+            if (configuration.isDebug())
+                System.out.println("Adding class to graph: " + className);
+
+            classGraph.add(loadClassByName(classLoader, className));
+        }
+    }
+
+    private static Class loadClassByName(URLClassLoader classLoader, String className) throws ClassNotFoundException {
+        return Class.forName(className, true, classLoader);
+    }
+
+    public static List<String> getClassNamesFromJar(File jarFile) throws IOException {
+        List<String> result = new ArrayList<>();
+        try (
+                JarInputStream jarInputStream = new JarInputStream(new FileInputStream(jarFile))
+        ) {
+            while (true) {
+                JarEntry jarEntry = jarInputStream.getNextJarEntry();
+                if (jarEntry == null)
+                    break;
+
+                if (isClassFile(jarEntry))
+                    result.add(getClassNameFromFileName(jarEntry));
+            }
+
+            return result;
+        }
+    }
+
+    private static boolean isClassFile(JarEntry jarEntry) {
+        return jarEntry.getName().endsWith(".class");
+    }
+
+    private static String getClassNameFromFileName(JarEntry jarEntry) {
+        String result = jarEntry.getName().replaceAll("/", "\\.");
+        return result.substring(0, result.lastIndexOf('.'));
+    }
+}
diff --git a/src/main/java/eu/svjatoslav/inspector/java/commandline/package-info.java b/src/main/java/eu/svjatoslav/inspector/java/commandline/package-info.java
new file mode 100644 (file)
index 0000000..c122358
--- /dev/null
@@ -0,0 +1,4 @@
+package eu.svjatoslav.inspector.java.commandline;
+/**
+ * This package contains JavaInspect commandline interface.
+ */
\ No newline at end of file