public static List < String > getPropertyValues ( ClassLoader classloader , String key ) { List < String > values = new ArrayList <> ( ) ; try { Enumeration < URL > resources = classloader . getResources ( "META-INF/MANIFEST.MF" ) ; while ( resources . hasMoreElements ( ) ) { Manifest manifest = new Manifest ( resources . nextElement ( ) . openStream ( ) ) ; Attributes attributes = manifest . getMainAttributes ( ) ; String value = attributes . getValue ( key ) ; if ( value != null ) { values . add ( value ) ; } } } catch ( IOException e ) { throw new SonarException ( "Fail to load manifests from classloader: " + classloader , e ) ; } return values ; }
Search for a property in all the manifests found in the classloader