You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/09/23 14:39:39 UTC

[GitHub] [maven] cstamas opened a new pull request, #806: Simpler G level metadata generation

cstamas opened a new pull request, #806:
URL: https://github.com/apache/maven/pull/806

   Just inspect deployed artifacts, try to find a plugin among them and reuse PluginDescriptor embedded in it.
   
   
   


-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] gnodet commented on pull request #806: [MNG-7547] Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
gnodet commented on PR #806:
URL: https://github.com/apache/maven/pull/806#issuecomment-1264606254

   The branch http://github.com/gnodet/maven/tree/plugin-metadata fixes the conflict and also remove the metadata from the v4 api.


-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on a diff in pull request #806: Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #806:
URL: https://github.com/apache/maven/pull/806#discussion_r978754793


##########
maven-resolver-provider/pom.xml:
##########
@@ -34,6 +34,10 @@ under the License.
   <description>Extensions to Maven Resolver for utilizing Maven POM and repository metadata.</description>
 
   <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+    </dependency>

Review Comment:
   Needed to grab PluginDescriptor model, that needs plexus... :cry: 



-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on a diff in pull request #806: Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #806:
URL: https://github.com/apache/maven/pull/806#discussion_r978757139


##########
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() );

Review Comment:
   Maybe just load up DOM and drop plugin-api/plexus as deps?



-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #806: [MNG-7547] Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #806:
URL: https://github.com/apache/maven/pull/806#discussion_r990610832


##########
maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java:
##########
@@ -35,42 +43,35 @@
 import org.eclipse.aether.metadata.Metadata;
 import org.eclipse.aether.util.ConfigUtils;
 
-import static java.util.Objects.requireNonNull;
-
 /**
- * Plugin G level metadata.
+ * Maven G level metadata generator.
+ * <p>
+ * Plugin metadata contains G level list of "prefix" to A mapping for plugins present under this G.
  */
 class PluginsMetadataGenerator
-    implements MetadataGenerator
+        implements MetadataGenerator
 {
-    private final PluginsMetadataInfoProvider pluginsMetadataInfoProvider;
-
-    private final Map<Object, PluginsMetadata> plugins;
+    private static final String PLUGIN_DESCRIPTOR_LOCATION = "META-INF/maven/plugin.xml";

Review Comment:
   All good, it is consistent with the rest of our code.



-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on a diff in pull request #806: Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
cstamas commented on code in PR #806:
URL: https://github.com/apache/maven/pull/806#discussion_r978755339


##########
maven-resolver-provider/pom.xml:
##########
@@ -103,6 +107,13 @@ under the License.
       <artifactId>failureaccess</artifactId>
       <optional>true</optional>
     </dependency>
+
+    <!-- Is must due PluginDescriptor as it uses Plexus stuff -->
+    <dependency>
+      <groupId>org.eclipse.sisu</groupId>
+      <artifactId>org.eclipse.sisu.plexus</artifactId>

Review Comment:
   Needed for model and as builder throws PlexusConfEx :sob: 
   
   Maybe just slurp in the plugin.xml as DOM?



-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on a diff in pull request #806: Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on pull request #806: [MNG-7547] Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #806:
URL: https://github.com/apache/maven/pull/806#issuecomment-1272264963

   @cstamas Can you please rebase? I want to test this as well.


-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on a diff in pull request #806: [MNG-7547] Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
michael-o commented on code in PR #806:
URL: https://github.com/apache/maven/pull/806#discussion_r990610911


##########
maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/PluginsMetadataGenerator.java:
##########
@@ -124,7 +126,50 @@ 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 ) )

Review Comment:
   Thanks, that is what I wanted to hear. We won't get so far w/o building the JAR.



-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] michael-o commented on pull request #806: [MNG-7547] Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
michael-o commented on PR #806:
URL: https://github.com/apache/maven/pull/806#issuecomment-1272488182

   Going through...


-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] cstamas commented on pull request #806: [MNG-7547] Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
cstamas commented on PR #806:
URL: https://github.com/apache/maven/pull/806#issuecomment-1272278473

   @michael-o rebased


-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [maven] gnodet merged pull request #806: [MNG-7547] Simpler G level metadata generation

Posted by GitBox <gi...@apache.org>.
gnodet merged PR #806:
URL: https://github.com/apache/maven/pull/806


-- 
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-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org