kriegaex commented on code in PR #110: URL: https://github.com/apache/maven-shade-plugin/pull/110#discussion_r1125615482
########## 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: I did it the same way @gnodet committed it a few lines down in `removeServicesFromJar`. If one gets a decent message, then the other should, too. What would you have me do? -- 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