data-collector/src/main/java/se/kth/depclean/experiments/ParentResolver.java
/**
     * Finds all dependencies inherited from the parent pom.
     */
Finds all dependencies inherited from the parent pom.
Finds all dependencies inherited from the parent pom .
public static HashSet findInheritedDependencies(Model pomModel, String parentPomDir) throws IOException, XmlPullParserException {
        HashSet inheritedDependencies = new HashSet();
        while (pomModel.getParent() != null) {
            Parent parent = pomModel.getParent();
            try {
            PomDownloader.downloadPom(parentPomDir, parent.getGroupId(), parent.getArtifactId(), parent.getVersion());
            Model parentPomModel = PomManipulator.readModel(new File(parentPomDir + "pom.xml"));
                if (parentPomModel.getDependencyManagement() != null) {
                    for (Dependency dep : parentPomModel.getDependencyManagement().getDependencies()) {
                        String dependency = dep.getGroupId() + ":" + dep.getArtifactId();
                        inheritedDependencies.add(dependency);
                    }
                }
                for (Dependency dep : parentPomModel.getDependencies()) {
                    String dependency = dep.getGroupId() + ":" + dep.getArtifactId();
                    inheritedDependencies.add(dependency);
                }
                pomModel = parentPomModel;
            }catch (Exception e){
                return inheritedDependencies;
            }
        }
        return inheritedDependencies;
    }
public static HashSet findInheritedDependencies ( Model pomModel , String parentPomDir ) throws IOException , XmlPullParserException { HashSet inheritedDependencies = new HashSet ( ) ; while ( pomModel . getParent ( ) != null ) { Parent parent = pomModel . getParent ( ) ; try { PomDownloader . downloadPom ( parentPomDir , parent . getGroupId ( ) , parent . getArtifactId ( ) , parent . getVersion ( ) ) ; Model parentPomModel = PomManipulator . readModel ( new File ( parentPomDir + "pom.xml" ) ) ; if ( parentPomModel . getDependencyManagement ( ) != null ) { for ( Dependency dep : parentPomModel . getDependencyManagement ( ) . getDependencies ( ) ) { String dependency = dep . getGroupId ( ) + ":" + dep . getArtifactId ( ) ; inheritedDependencies . add ( dependency ) ; } } for ( Dependency dep : parentPomModel . getDependencies ( ) ) { String dependency = dep . getGroupId ( ) + ":" + dep . getArtifactId ( ) ; inheritedDependencies . add ( dependency ) ; } pomModel = parentPomModel ; } catch ( Exception e ) { return inheritedDependencies ; } } return inheritedDependencies ; }
Finds all dependencies inherited from the parent pom.
Finds all dependencies inherited from the parent pom .