-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from ABHAY0O7/multi-module-support
Multi module support
- Loading branch information
Showing
4 changed files
with
201 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
depclean-maven-plugin/src/main/java/se/kth/depclean/util/ChangeDependencyResultUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package se.kth.depclean.util; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* This will help in changing the status of the dependencies involved in | ||
* dependent modules of a multi-module java project. | ||
*/ | ||
public class ChangeDependencyResultUtils { | ||
|
||
private final String dependencyCoordinate; | ||
private final String module; | ||
private final String type; | ||
|
||
/** | ||
* Ctor. | ||
* | ||
* @param dependencyCoordinate Target dependency. | ||
* @param module Target module. | ||
* @param type Debloat status. | ||
*/ | ||
public ChangeDependencyResultUtils(final String dependencyCoordinate, | ||
final String module, | ||
final String type) { | ||
this.dependencyCoordinate = dependencyCoordinate; | ||
this.module = module; | ||
this.type = type; | ||
} | ||
|
||
// Getters ------------------------------------------------------------- | ||
public String getDependencyCoordinate() { | ||
return dependencyCoordinate; | ||
} | ||
|
||
public String getModule() { | ||
return module; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
/** | ||
* Return the new type (status) of the dependency. | ||
* | ||
* @return New type | ||
*/ | ||
public String getNewType() { | ||
// Changing the status of debloat. | ||
String newType; | ||
if (Objects.equals(type, "unusedDirect")) { | ||
newType = "usedDirect"; | ||
} else if (Objects.equals(type, "unusedTransitive")) { | ||
newType = "usedTransitive"; | ||
} else { | ||
newType = "usedInherited"; | ||
} | ||
return newType; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
depclean-maven-plugin/src/main/java/se/kth/depclean/util/ResultsUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package se.kth.depclean.util; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Collects the data from the report generated by depclean on any module of the project. | ||
*/ | ||
public class ResultsUtils { | ||
|
||
private final Set<String> unusedDirectArtifactsCoordinates; | ||
private final Set<String> unusedInheritedArtifactsCoordinates; | ||
private final Set<String> unusedTransitiveArtifactsCoordinates; | ||
private final Set<String> allUnusedDependenciesCoordinates = new HashSet<>(); | ||
|
||
/** | ||
* Ctor. | ||
*/ | ||
public ResultsUtils(final Set<String> unusedDirectArtifactsCoordinates, | ||
final Set<String> unusedInheritedArtifactsCoordinates, | ||
final Set<String> unusedTransitiveArtifactsCoordinates) { | ||
this.unusedDirectArtifactsCoordinates = unusedDirectArtifactsCoordinates; | ||
this.unusedInheritedArtifactsCoordinates = unusedInheritedArtifactsCoordinates; | ||
this.unusedTransitiveArtifactsCoordinates = unusedTransitiveArtifactsCoordinates; | ||
} | ||
|
||
// Getters ------------------------------------------------------------------------------ | ||
|
||
/** | ||
* Collect all the unused dependencies from the provided result. | ||
* | ||
* @return A set of all unused dependencies | ||
*/ | ||
public Set<String> getAllUnusedDependenciesCoordinates() { | ||
/* Collecting only the unused dependencies, cause in multi-module analysis, build | ||
will only fail when any unused dependencies iof one module is used by another. */ | ||
allUnusedDependenciesCoordinates.addAll(unusedDirectArtifactsCoordinates); | ||
allUnusedDependenciesCoordinates.addAll(unusedInheritedArtifactsCoordinates); | ||
allUnusedDependenciesCoordinates.addAll(unusedTransitiveArtifactsCoordinates); | ||
return allUnusedDependenciesCoordinates; | ||
} | ||
|
||
/** | ||
* To get the type (status) of a dependency. | ||
* | ||
* @param coordinates The dependency. | ||
* @return Type (status) | ||
*/ | ||
public String getType(final String coordinates) { | ||
if (unusedDirectArtifactsCoordinates.contains(coordinates)) { | ||
return "unusedDirect"; | ||
} else if (unusedTransitiveArtifactsCoordinates.contains(coordinates)) { | ||
return "unusedTransitive"; | ||
} else { | ||
return "unusedInherited"; | ||
} | ||
} | ||
} |