import eu.svjatoslav.inspector.java.structure.ClassGraph;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
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) {
- if (args.length == 0) {
- System.err.println("usage: javainspect [PROJECT_DIR] [PACKAGE_GLOB] [GRAPH_NAME]");
- System.exit(1);
- }
+ public static void main(String[] args) throws MalformedURLException, ClassNotFoundException {
+ CommandlineConfiguration commandlineConfiguration = new CommandlineConfiguration(args);
+ System.out.println("Commandline config validated");
+
+ File jarFile = commandlineConfiguration.jarFile.getValue();
+
+ URLClassLoader classLoader = new URLClassLoader(
+ new URL[]{jarFile.toURL()},
+ commandlineConfiguration.getClass().getClassLoader());
+
+ Class classToLoad = Class.forName("eu.svjatoslav.sixth.e3d.gui.GuiComponent", true, classLoader);
- String projectDir = args[0];
- String packageGlob = args[1];
- String graphName = args[2];
ClassGraph cg = new ClassGraph();
cg.setTargetDirectoryPath(getProperty("user.dir") + separator);
- cg.addProject(projectDir);
- cg.whitelistClassGlob(packageGlob);
+// cg.addProject(projectDir);
+// cg.whitelistClassGlob(packageGlob);
cg.setKeepDotFile(true);
- cg.generateGraph(graphName);
+ cg.add(classToLoad);
+ cg.generateGraph(commandlineConfiguration.graphName.getValue());
}
}