cstamas commented on code in PR #806:
URL: https://github.com/apache/maven/pull/806#discussion_r978756688


##########
maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java:
##########
@@ -124,7 +128,46 @@ public Collection<? extends Metadata> finish( Collection<? 
extends Artifact> art
                 }
             }
         }
-
         return plugins.values();
     }
+
+    private PluginInfo extractPluginInfo( Artifact artifact )
+    {
+        // sanity: jar, no classifier and file exists
+        if ( artifact != null
+                && "jar".equals( artifact.getExtension() )
+                && "".equals( artifact.getClassifier() )
+                && artifact.getFile() != null )
+        {
+            Path artifactPath = artifact.getFile().toPath();
+            if ( Files.isRegularFile( artifactPath ) )
+            {
+                try ( JarFile artifactJar = new JarFile( 
artifactPath.toFile(), false ) )
+                {
+                    ZipEntry pluginDescriptorEntry = artifactJar.getEntry( 
PLUGIN_DESCRIPTOR_LOCATION );
+
+                    if ( pluginDescriptorEntry != null )
+                    {
+                        InputStream is = artifactJar.getInputStream( 
pluginDescriptorEntry );
+
+                        Reader reader = ReaderFactory.newXmlReader( is );
+
+                        PluginDescriptor pluginDescriptor =
+                                pluginDescriptorBuilder.build( reader, 
artifactPath.toAbsolutePath().toString() );
+
+                        return new PluginInfo(
+                                pluginDescriptor.getGroupId(),
+                                pluginDescriptor.getArtifactId(),
+                                pluginDescriptor.getGoalPrefix(),
+                                pluginDescriptor.getName() );
+                    }
+                }
+                catch ( Exception e )
+                {
+                    // ignore it for now

Review Comment:
   This is too broad, but for example maven's ArtifactDeployerTest and 
ArtifactInstallerTest (maven-compat) uses invalid JAR for tests.... :sob: 



-- 
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

Reply via email to