public class CommandlineConfiguration {
+ public FileParameter jarFile;
+ public StringParameter graphName;
+
public CommandlineConfiguration (String args[]){
Parser parser = buildCommandlineParameterParser();
if (!parser.parse(args)) {
parser.showHelp();
+ return;
}
+
}
public Parser buildCommandlineParameterParser() {
Parser parser = new Parser();
- parser.add(
+ jarFile = parser.add(
new FileParameter("JAR file"))
.mustExist()
.addAliases("-j");
- parser.add(
+ graphName = parser.add(
new StringParameter("graph name"))
.setMandatory()
.addAliases("-n");
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) {
+ 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);
+
+
ClassGraph cg = new ClassGraph();
cg.setTargetDirectoryPath(getProperty("user.dir") + separator);
// cg.addProject(projectDir);
// cg.whitelistClassGlob(packageGlob);
-// cg.setKeepDotFile(true);
-// cg.generateGraph(graphName);
+ cg.setKeepDotFile(true);
+ cg.add(classToLoad);
+ cg.generateGraph(commandlineConfiguration.graphName.getValue());
}
}