private static void findClasspathOrderRec ( final ClasspathElement currClasspathElement , final Set < ClasspathElement > visitedClasspathElts , final List < ClasspathElement > order ) { if ( visitedClasspathElts . add ( currClasspathElement ) ) { if ( ! currClasspathElement . skipClasspathElement ) { // Don't add a classpath element if it is marked to be skipped. order . add ( currClasspathElement ) ; } // Whether or not a classpath element should be skipped, add any child classpath elements that are // not marked to be skipped (i.e. keep recursing) for ( final ClasspathElement childClasspathElt : currClasspathElement . childClasspathElementsOrdered ) { findClasspathOrderRec ( childClasspathElt , visitedClasspathElts , order ) ; } } }
Recursively perform a depth - first search of jar interdependencies breaking cycles if necessary to determine the final classpath element order .