Skip to content

Commit

Permalink
fix: wrong main for dep analyser
Browse files Browse the repository at this point in the history
terminalsin committed Dec 12, 2024
1 parent 2aebc81 commit 2d818f0
Showing 3 changed files with 18 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.example.dependencyanalyzer;
package dev.skidfuscator.dependanalysis;

import dev.skidfuscator.dependanalysis.DependencyClassHierarchy;
import dev.skidfuscator.dependanalysis.DependencyResult;
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package dev.skidfuscator.dependanalysis;

import lombok.Data;
import lombok.Getter;

import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

/**
* DependencyResult provides a structured representation of the required dependencies.
* Each JarDependency represents an external jar that is needed, containing the classes
* from that jar that are required and reasons for their necessity.
*/
@Getter
public class DependencyResult {
private final List<JarDependency> jarDependencies;

public DependencyResult(List<JarDependency> jarDependencies) {
this.jarDependencies = jarDependencies;
}

public List<JarDependency> getJarDependencies() {
return jarDependencies;
}

public void printReport() {
System.out.println("Required Dependencies:");
System.out.println("=====================\n");
@@ -40,39 +41,25 @@ public void printReport() {
System.out.println();
}
}
@Data
public static class JarDependency {
private final Path jarPath;
private final List<ClassDependency> classesNeeded;

public JarDependency(Path jarPath, List<ClassDependency> classesNeeded) {
this.jarPath = jarPath;
this.classesNeeded = classesNeeded;
}

public Path getJarPath() {
return jarPath;
}

public List<ClassDependency> getClassesNeeded() {
return classesNeeded;
@Override
public String toString() {
return "[" + this.getJarPath().getFileName() + "]"
+ "\nClasses [" + this.getClassesNeeded().size() + "]:"
+ "\n" + this.getClassesNeeded().stream()
.map(e -> " - " + e.getClassName() + " (" + String.join(", ", e.getReasons()) + ")")
.collect(Collectors.joining("\n"))
;
}
}

@Data
public static class ClassDependency {
private final String className;
private final List<String> reasons;

public ClassDependency(String className, List<String> reasons) {
this.className = className;
this.reasons = reasons;
}

public String getClassName() {
return className;
}

public List<String> getReasons() {
return reasons;
}
}
}
Original file line number Diff line number Diff line change
@@ -22,10 +22,10 @@ public static void main(String[] args) throws Exception {
Path libs = Paths.get(args[1]);

DependencyAnalyzer analyzer = new DependencyAnalyzer(mainJar, libs);
Set<Path> requiredJars = analyzer.analyze();
DependencyResult requiredJars = analyzer.analyze();

System.out.println("Required jars:");
for (Path jar : requiredJars) {
for (DependencyResult.JarDependency jar : requiredJars.getJarDependencies()) {
System.out.println(" - " + jar);
}
}

0 comments on commit 2d818f0

Please sign in to comment.