Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip specialization if no used types in dependency #14

Merged
merged 2 commits into from
Nov 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/main/java/se/kth/deptrim/core/Trimmer.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ public Set<DependencyOriginalAndTrimmed> trimLibClasses(ProjectDependencyAnalysi
.forEach((key, value) -> {
String dependencyCoordinates = key.getGroupId() + ":" + key.getDependencyId() + ":" + key.getVersion();
// debloating only the dependencies provided by the user and if the scope is not ignored
if (finalTrimDependencies.contains(dependencyCoordinates) && !ignoreScopes.contains(key.getScope()) && !dependencyCoordinates.equals(thisProjectCoordinates)) {
if (!value.getUsedTypes().isEmpty()
&& finalTrimDependencies.contains(dependencyCoordinates)
&& !ignoreScopes.contains(key.getScope())
&& !dependencyCoordinates.equals(thisProjectCoordinates)) {
log.info("Trimming dependency " + dependencyCoordinates);
Set<ClassName> unusedTypes = new HashSet<>(value.getAllTypes());
unusedTypes.removeAll(value.getUsedTypes());
Expand Down