You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2020/03/29 17:45:42 UTC

[maven] branch MNG-6866 updated (5f96655 -> 9f070e7)

This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a change to branch MNG-6866
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard 5f96655  [MNG-6866] extract methods, apply SLA, introduce mass mojo adding
 discard e166bab  [MNG-6872] - Found CVEs in your dependencies - plexus-utils (tests)
 discard db94a24  [MNG-6874] - Upgrade Maven Parent to 34
 discard 782e8f8  Refactor getLocalRepository() in tests by using the repositorySystem
 discard 8467ce5  use https://repository.a.o/ for Apache SNAPSHOT plugins
     add 9ae008a  use https://repository.a.o/ for Apache SNAPSHOT plugins
     add f2e9afd  Refactor getLocalRepository() in tests by using the repositorySystem
     add d204f02  [MNG-6874] - Upgrade Maven Parent to 34
     add 9e92a93  [MNG-6872] - Found CVEs in your dependencies - plexus-utils (tests)
     add 5cdb833  [MNG-5669] Fix infinitive loop in case pom.xml is being updated during the process (e.g. maven-shade-plugin writing reduced-pom with excluded dependencies)
     add c548ce5  Adjust JDKs in Jenkinsfile
     new 9f070e7  [MNG-6866] extract methods, apply SLA, introduce mass mojo adding

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5f96655)
            \
             N -- N -- N   refs/heads/MNG-6866 (9f070e7)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 Jenkinsfile                                        |  2 +-
 .../maven/model/building/DefaultModelBuilder.java  | 27 +++++++++++++---------
 2 files changed, 17 insertions(+), 12 deletions(-)


[maven] 01/01: [MNG-6866] extract methods, apply SLA, introduce mass mojo adding

Posted by kh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

khmarbaise pushed a commit to branch MNG-6866
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 9f070e7dc151d46502ac59ed1b8152aa2efc8305
Author: Lewinski, Arne <ar...@DE-L072609.groupinfra.com>
AuthorDate: Sun Feb 16 20:42:47 2020 +0100

    [MNG-6866] extract methods, apply SLA, introduce mass mojo adding
---
 .../maven/plugin/descriptor/PluginDescriptor.java  |  10 ++
 .../plugin/descriptor/PluginDescriptorBuilder.java | 128 +++++++++++++++------
 2 files changed, 101 insertions(+), 37 deletions(-)

diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
index e05d86a..01ead82 100644
--- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
+++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java
@@ -436,4 +436,14 @@ public class PluginDescriptor
         }
     }
 
+    public void addMojos( List<MojoDescriptor> mojos )
+        throws DuplicateMojoDescriptorException
+    {
+        for ( MojoDescriptor mojoDescriptor : mojos )
+        {
+            addMojo( mojoDescriptor );
+        }
+
+    }
+
 }
diff --git a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
index 3df7ab4..5747d16 100644
--- a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
+++ b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.java
@@ -46,49 +46,102 @@ public class PluginDescriptorBuilder
     public PluginDescriptor build( Reader reader, String source )
         throws PlexusConfigurationException
     {
-        PlexusConfiguration c = buildConfiguration( reader );
+        return build( source, buildConfiguration( reader ) );
+    }
 
+    private PluginDescriptor build( String source, PlexusConfiguration c )
+        throws PlexusConfigurationException
+    {
         PluginDescriptor pluginDescriptor = new PluginDescriptor();
 
         pluginDescriptor.setSource( source );
-        pluginDescriptor.setGroupId( c.getChild( "groupId" ).getValue() );
-        pluginDescriptor.setArtifactId( c.getChild( "artifactId" ).getValue() );
-        pluginDescriptor.setVersion( c.getChild( "version" ).getValue() );
-        pluginDescriptor.setGoalPrefix( c.getChild( "goalPrefix" ).getValue() );
+        pluginDescriptor.setGroupId( extractGroupId( c ) );
+        pluginDescriptor.setArtifactId( extractArtifactId( c ) );
+        pluginDescriptor.setVersion( extractVersion( c ) );
+        pluginDescriptor.setGoalPrefix( extractGoalPrefix( c ) );
 
-        pluginDescriptor.setName( c.getChild( "name" ).getValue() );
-        pluginDescriptor.setDescription( c.getChild( "description" ).getValue() );
+        pluginDescriptor.setName( extractName( c ) );
+        pluginDescriptor.setDescription( extractDescription( c ) );
 
-        String isolatedRealm = c.getChild( "isolatedRealm" ).getValue();
+        pluginDescriptor.setIsolatedRealm( extractIsolatedRealm( c ) );
+        pluginDescriptor.setInheritedByDefault( extractInheritedByDefault( c ) );
 
-        if ( isolatedRealm != null )
+        pluginDescriptor.addMojos( extractMojos( c, pluginDescriptor ) );
+
+        pluginDescriptor.setDependencies( extractComponentDependencies( c ) );
+
+        return pluginDescriptor;
+    }
+
+    private String extractGroupId( PlexusConfiguration c )
+    {
+        return c.getChild( "groupId" ).getValue();
+    }
+
+    private String extractArtifactId( PlexusConfiguration c )
+    {
+        return c.getChild( "artifactId" ).getValue();
+    }
+
+    private String extractVersion( PlexusConfiguration c )
+    {
+        return c.getChild( "version" ).getValue();
+    }
+
+    private String extractGoalPrefix( PlexusConfiguration c )
+    {
+        return c.getChild( "goalPrefix" ).getValue();
+    }
+
+    private String extractName( PlexusConfiguration c )
+    {
+        return c.getChild( "name" ).getValue();
+    }
+
+    private String extractDescription( PlexusConfiguration c )
+    {
+        return c.getChild( "description" ).getValue();
+    }
+
+    private List<MojoDescriptor> extractMojos( PlexusConfiguration c, PluginDescriptor pluginDescriptor )
+        throws PlexusConfigurationException
+    {
+        List<MojoDescriptor> mojos = new ArrayList<>();
+
+        PlexusConfiguration[] mojoConfigurations = c.getChild( "mojos" ).getChildren( "mojo" );
+
+        for ( PlexusConfiguration component : mojoConfigurations )
         {
-            pluginDescriptor.setIsolatedRealm( Boolean.parseBoolean( isolatedRealm ) );
+            mojos.add( buildComponentDescriptor( component, pluginDescriptor ) );
+
         }
+        return mojos;
+    }
 
+    private boolean extractInheritedByDefault( PlexusConfiguration c )
+    {
         String inheritedByDefault = c.getChild( "inheritedByDefault" ).getValue();
 
         if ( inheritedByDefault != null )
         {
-            pluginDescriptor.setInheritedByDefault( Boolean.parseBoolean( inheritedByDefault ) );
+            return Boolean.parseBoolean( inheritedByDefault );
         }
+        return false;
+    }
 
-        // ----------------------------------------------------------------------
-        // Components
-        // ----------------------------------------------------------------------
-
-        PlexusConfiguration[] mojoConfigurations = c.getChild( "mojos" ).getChildren( "mojo" );
+    private boolean extractIsolatedRealm( PlexusConfiguration c )
+    {
+        String isolatedRealm = c.getChild( "isolatedRealm" ).getValue();
 
-        for ( PlexusConfiguration component : mojoConfigurations )
+        if ( isolatedRealm != null )
         {
-            MojoDescriptor mojoDescriptor = buildComponentDescriptor( component, pluginDescriptor );
-
-            pluginDescriptor.addMojo( mojoDescriptor );
+            return Boolean.parseBoolean( isolatedRealm );
         }
+        return false;
+    }
 
-        // ----------------------------------------------------------------------
-        // Dependencies
-        // ----------------------------------------------------------------------
+    private List<ComponentDependency> extractComponentDependencies( PlexusConfiguration c )
+    {
 
         PlexusConfiguration[] dependencyConfigurations = c.getChild( "dependencies" ).getChildren( "dependency" );
 
@@ -96,22 +149,23 @@ public class PluginDescriptorBuilder
 
         for ( PlexusConfiguration d : dependencyConfigurations )
         {
-            ComponentDependency cd = new ComponentDependency();
-
-            cd.setArtifactId( d.getChild( "artifactId" ).getValue() );
-
-            cd.setGroupId( d.getChild( "groupId" ).getValue() );
+            dependencies.add( extractComponentDependency( d ) );
+        }
+        return dependencies;
+    }
 
-            cd.setType( d.getChild( "type" ).getValue() );
+    private ComponentDependency extractComponentDependency( PlexusConfiguration d )
+    {
+        ComponentDependency cd = new ComponentDependency();
 
-            cd.setVersion( d.getChild( "version" ).getValue() );
+        cd.setArtifactId( extractArtifactId( d ) );
 
-            dependencies.add( cd );
-        }
+        cd.setGroupId( extractGroupId( d ) );
 
-        pluginDescriptor.setDependencies( dependencies );
+        cd.setType( d.getChild( "type" ).getValue() );
 
-        return pluginDescriptor;
+        cd.setVersion( extractVersion( d ) );
+        return cd;
     }
 
     @SuppressWarnings( "checkstyle:methodlength" )
@@ -190,7 +244,7 @@ public class PluginDescriptorBuilder
 
         mojo.setInstantiationStrategy( c.getChild( "instantiationStrategy" ).getValue() );
 
-        mojo.setDescription( c.getChild( "description" ).getValue() );
+        mojo.setDescription( extractDescription( c ) );
 
         PlexusConfiguration dependencyResolution = c.getChild( "requiresDependencyResolution", false );
 
@@ -274,7 +328,7 @@ public class PluginDescriptorBuilder
         {
             Parameter parameter = new Parameter();
 
-            parameter.setName( d.getChild( "name" ).getValue() );
+            parameter.setName( extractName( d ) );
 
             parameter.setAlias( d.getChild( "alias" ).getValue() );
 
@@ -294,7 +348,7 @@ public class PluginDescriptorBuilder
                 parameter.setEditable( editable == null || Boolean.parseBoolean( editable ) );
             }
 
-            parameter.setDescription( d.getChild( "description" ).getValue() );
+            parameter.setDescription( extractDescription( d ) );
 
             parameter.setDeprecated( d.getChild( "deprecated" ).getValue() );