private void collectClassDependencies ( Clazz classInstance , Analyzer analyzer ) throws Exception { // retrieve the imports from the known class path Set < TypeRef > importedClasses = classInstance . parseClassFile ( ) ; for ( TypeRef importedClass : importedClasses ) { if ( canBeSkipped ( importedClass ) ) // validate the import continue ; // find the class in the classpath Clazz classInstanceImported = analyzer . findClass ( importedClass ) ; if ( classInstanceImported == null ) error ( "Referenced class " + importedClass . getFQN ( ) + " not found for inclusion in jar. It is imported by " + classInstance . getAbsolutePath ( ) ) ; // update the imports map importedReferencedTypes . add ( importedClass ) ; allReferencedTypes . add ( importedClass ) ; // collect dependencies introduced by the imports collectClassDependencies ( classInstanceImported , analyzer ) ; } }
Collect the imports from a class and add the imported classes to the map of all known classes importedReferencedTypes is updated to contain newly added imports allReferencedTypes is updated to avoid the duplicated process