michael-o commented on code in PR #110:
URL: 
https://github.com/apache/maven-shade-plugin/pull/110#discussion_r1125637146


##########
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:
   Agreed, make it consistent with the rest. Improving those is a different 
topic.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to