kriegaex commented on code in PR #110: URL: https://github.com/apache/maven-shade-plugin/pull/110#discussion_r1125638854
########## src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java: ########## @@ -156,6 +204,43 @@ private void removeServices( final MavenProject project, final Clazzpath cp ) while ( repeatScan ); } + private boolean removeServicesFromDir( Clazzpath cp, Set<Clazz> neededClasses, String fileName ) + { + final File servicesDir = new File( fileName, "META-INF/services/" ); + if ( !servicesDir.isDirectory() ) + { + return false; + } + final File[] serviceProviderConfigFiles = servicesDir.listFiles(); + if ( serviceProviderConfigFiles == null || serviceProviderConfigFiles.length == 0 ) + { + return false; + } + + boolean repeatScan = false; + for ( File serviceProviderConfigFile : serviceProviderConfigFiles ) + { + final String serviceClassName = serviceProviderConfigFile.getName(); + final boolean isNeededClass = neededClasses.contains( cp.getClazz( serviceClassName ) ); + if ( !isNeededClass ) + { + continue; + } + + try ( final BufferedReader configFileReader = new BufferedReader( + new InputStreamReader( new FileInputStream( serviceProviderConfigFile ), UTF_8 ) ) ) + { + // check whether the found classes use services in turn + repeatScan |= scanServiceProviderConfigFile( cp, configFileReader ); + } + catch ( final IOException e ) + { + log.warn( e.getMessage() ); Review Comment: Actually, it was easy enough to comply with your wish (see the new commit). Secondly, Guillaume's authorship of the code comes from his squashing one of my previous PRs, so actually it is fair enough for me to improve both places. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org