private List < String > locatePomProperties ( ) { List < String > propertiesFiles = new ArrayList <> ( ) ; List < URL > packageUrls = ClasspathUtils . getResources ( getResourceBasePath ( ) ) ; for ( URL packageUrl : packageUrls ) { if ( packageUrl . getProtocol ( ) . equals ( "jar" ) ) { // We only care about Webjars jar files log . debug ( "Scanning {}" , packageUrl ) ; try { String jar = packageUrl . toString ( ) . substring ( "jar:" . length ( ) ) . split ( "!" ) [ 0 ] ; File file = new File ( new URI ( jar ) ) ; try ( JarInputStream is = new JarInputStream ( new FileInputStream ( file ) ) ) { JarEntry entry = null ; while ( ( entry = is . getNextJarEntry ( ) ) != null ) { if ( ! entry . isDirectory ( ) && entry . getName ( ) . endsWith ( "pom.properties" ) ) { propertiesFiles . add ( entry . getName ( ) ) ; } } } } catch ( URISyntaxException | IOException e ) { throw new PippoRuntimeException ( "Failed to get classes for package '{}'" , packageUrl ) ; } } } return propertiesFiles ; }
Locate all Webjars Maven pom . properties files on the classpath .