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

kwin pushed a commit to branch 
feature/generate-plugin-descriptor-bean-and-reader-from-model
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 6afdb47604cb70eed983979b1be3afd28c4844cb
Author: Konrad Windszus <k...@apache.org>
AuthorDate: Mon Oct 24 13:21:30 2022 +0200

    [MNG-7588] generate reader and some beans automatically for plugin
    descriptor
    
    WIP
---
 maven-plugin-api/pom.xml                           |  70 +++-
 .../InvalidPluginDescriptorException.java          |   7 +-
 .../maven/plugin/descriptor/MojoDescriptor.java    | 376 ++++++++++++++++++++-
 .../apache/maven/plugin/descriptor/Parameter.java  | 207 ------------
 .../maven/plugin/descriptor/PluginDescriptor.java  | 216 +++++++++++-
 .../plugin/descriptor/PluginDescriptorBuilder.java | 148 +-------
 .../maven/plugin/descriptor/Requirement.java       |  72 ----
 maven-plugin-api/src/main/mdo/plugin.mdo           |  78 ++++-
 .../plugin/descriptor/MojoDescriptorTest.java      |   8 +-
 .../descriptor/PluginDescriptorBuilderTest.java    |   2 +-
 ...st.java => PluginDescriptorXpp3ReaderTest.java} |  18 +-
 11 files changed, 753 insertions(+), 449 deletions(-)

diff --git a/maven-plugin-api/pom.xml b/maven-plugin-api/pom.xml
index 198a90c10..1fa841f43 100644
--- a/maven-plugin-api/pom.xml
+++ b/maven-plugin-api/pom.xml
@@ -61,7 +61,7 @@ under the License.
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
-        <version>2.0.0</version>
+        <version>2.1.0-SNAPSHOT</version>
         <configuration>
           <models>
             <model>src/main/mdo/lifecycle.mdo</model>
@@ -69,10 +69,22 @@ under the License.
           <version>1.0.0</version>
         </configuration>
         <executions>
-          <execution>
-            <id>modello</id>
-            <phase>none</phase>
-          </execution>
+<!--           <execution> -->
+<!--             <id>modello</id> -->
+<!--             <phase>none</phase> -->
+<!--           </execution> -->
+<!--           <execution> -->
+<!--             <id>modello-plugindescriptor-reader</id> -->
+<!--             <goals> -->
+<!--                 <goal>xpp3-reader</goal> -->
+<!--             </goals> -->
+<!--             <configuration> -->
+<!--               <models> -->
+<!--                 <model>src/main/mdo/plugin.mdo</model> -->
+<!--               </models> -->
+<!--               <version>1.1.0</version> -->
+<!--             </configuration> -->
+<!--           </execution> -->
           <execution>
             <id>modello-site-docs</id>
             <phase>pre-site</phase>
@@ -90,7 +102,7 @@ under the License.
         <artifactId>modello-plugin-velocity</artifactId>
         <executions>
           <execution>
-            <id>velocity</id>
+            <id>velocity-lifecycle</id>
             <phase>generate-sources</phase>
             <goals>
               <goal>velocity</goal>
@@ -112,6 +124,52 @@ under the License.
               </params>
             </configuration>
           </execution>
+          <execution>
+            <id>velocity-plugin</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>velocity</goal>
+            </goals>
+            <configuration>
+              <version>1.1.0</version>
+              <models>
+                <model>src/main/mdo/plugin.mdo</model>
+              </models>
+              <templates>
+                <template>src/main/mdo/model.vm</template>
+                <template>src/main/mdo/reader.vm</template>
+              </templates>
+              <params>
+                
<param>packageModelV3=org.apache.maven.plugin.descriptor</param>
+                
<param>packageModelV4=org.apache.maven.plugin.descriptor</param>
+                
<param>packageToolV4=org.apache.maven.plugin.descriptor.io.xpp3</param>
+              </params>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-clean-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>remove-superfluous-generated-classes</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>clean</goal>
+            </goals>
+            <configuration>
+              <excludeDefaultDirectories>true</excludeDefaultDirectories>
+              <filesets>
+                <fileset>
+                  
<directory>target/generated-sources/modello/org/apache/maven/plugin/descriptor</directory>
+                  <includes>
+                    <include>MojoDescriptor.java</include>
+                    <include>PluginDescriptor.java</include>
+                  </includes>
+                </fileset>
+              </filesets>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
     </plugins>
diff --git 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/InvalidPluginDescriptorException.java
 
b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/InvalidPluginDescriptorException.java
index f63fd26ce..12f9655c5 100644
--- 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/InvalidPluginDescriptorException.java
+++ 
b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/InvalidPluginDescriptorException.java
@@ -19,18 +19,19 @@ package org.apache.maven.plugin.descriptor;
  * under the License.
  */
 
-import org.codehaus.plexus.configuration.PlexusConfigurationException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 /**
  * InvalidPluginDescriptorException
  */
 public class InvalidPluginDescriptorException
-    extends PlexusConfigurationException
+    extends XmlPullParserException
 {
 
     public InvalidPluginDescriptorException( String message, Throwable cause )
     {
-        super( message, cause );
+        super( message );
+        this.initCause( cause );
     }
 
     public InvalidPluginDescriptorException( String message )
diff --git 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
 
b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
index 80829332a..ea6c3d40d 100644
--- 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
+++ 
b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/MojoDescriptor.java
@@ -20,15 +20,20 @@ package org.apache.maven.plugin.descriptor;
  */
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.NotThreadSafe;
+import org.apache.maven.api.xml.Dom;
 import org.apache.maven.plugin.Mojo;
 import org.codehaus.plexus.component.repository.ComponentDescriptor;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 /**
  * The bean containing the Mojo descriptor.<br>
@@ -36,8 +41,8 @@ import 
org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
  * <a href="https://maven.apache.org/developers/mojo-api-specification.html";>
  * https://maven.apache.org/developers/mojo-api-specification.html</a>
  *
- * TODO is there a need for the delegation of MavenMojoDescriptor to this?
- * Why not just extend ComponentDescriptor here?
+ * This file is not generated from the underlying Modello model as it needs to 
extend {@link ComponentDescriptor}
+ * which is not based on a model.
  */
 public class MojoDescriptor
     extends ComponentDescriptor<Mojo>
@@ -200,12 +205,13 @@ public class MojoDescriptor
      * @param parameters the new list of parameters
      * @throws DuplicateParameterException if any
      */
-    public void setParameters( List<Parameter> parameters )
+    public void setParameters( Collection<Parameter> parameters )
         throws DuplicateParameterException
     {
         this.parameters.clear();
         for ( Parameter parameter : parameters )
         {
+            // enrich parameter with information from configuration (already 
available?)
             addParameter( parameter );
         }
     }
@@ -223,10 +229,24 @@ public class MojoDescriptor
                 + " has been declared multiple times in mojo with goal: " + 
getGoal() + " (implementation: "
                 + getImplementation() + ")" );
         }
-
+        if ( mojoConfiguration != null )
+        {
+            setParameterValuesFromMojoConfiguration( parameter );
+        }
         parameters.add( parameter );
     }
 
+    private boolean setParameterValuesFromMojoConfiguration( Parameter 
parameter )
+    {
+        PlexusConfiguration paramConfig = mojoConfiguration.getChild( 
parameter.getName(), false );
+        if ( paramConfig != null )
+        {
+            parameter.setExpression( paramConfig.getValue( null ) );
+            parameter.setDefaultValue( paramConfig.getAttribute( 
"default-value" ) );
+            return true;
+        }
+        return false;
+    }
     /**
      * @return the list parameters as a Map (keyed by {@link 
Parameter#getName()}) that is built from
      * {@link #parameters} list on each call. In other words, the map returned 
is built on fly and is a copy.
@@ -452,6 +472,10 @@ public class MojoDescriptor
     public void setMojoConfiguration( PlexusConfiguration mojoConfiguration )
     {
         this.mojoConfiguration = mojoConfiguration;
+        for ( Parameter parameter : parameters )
+        {
+            setParameterValuesFromMojoConfiguration( parameter );
+        }
     }
 
     /** {@inheritDoc} */
@@ -668,6 +692,17 @@ public class MojoDescriptor
         this.v4Api = v4Api;
     }
 
+    public final void setMojoConfiguration( final Xpp3Dom configuration )
+    {
+        setMojoConfiguration( new XmlPlexusConfiguration( configuration ) );
+    }
+
+
+    public void setRequirements( Collection<Requirement> requirements )
+    {
+        requirements.stream().map( Requirement::toComponentRequirement 
).forEach( this::addRequirement );
+    }
+
     /**
      * Creates a shallow copy of this mojo descriptor.
      */
@@ -684,4 +719,337 @@ public class MojoDescriptor
         }
     }
 
+
+    /**
+     * Creates a new MojoDescriptor instance.
+     * Equivalent to {@code newInstance( true )}.
+     * @throws DuplicateParameterException 
+     * @see #newInstance(boolean)
+     */
+    @Nonnull
+    public static MojoDescriptor newInstance() throws 
DuplicateParameterException
+    {
+        return newInstance( true );
+    }
+
+    /**
+     * Creates a new MojoDescriptor instance using default values or not.
+     * Equivalent to {@code newBuilder( withDefaults ).build()}.
+     * @throws DuplicateParameterException 
+     */
+    @Nonnull
+    public static MojoDescriptor newInstance( boolean withDefaults ) throws 
DuplicateParameterException
+    {
+        return newBuilder( withDefaults ).build();
+    }
+
+    /**
+     * Creates a new MojoDescriptor builder instance.
+     * Equivalent to {@code newBuilder( true )}.
+     * @see #newBuilder(boolean)
+     */
+    @Nonnull
+    public static Builder newBuilder()
+    {
+        return newBuilder( true );
+    }
+
+    /**
+     * Creates a new MojoDescriptor builder instance using default values or 
not.
+     */
+    @Nonnull
+    public static Builder newBuilder( boolean withDefaults )
+    {
+        return new Builder( withDefaults );
+    }
+
+    /**
+     * Builder class used to create MojoDescriptor instances.
+     * @see #with()
+     * @see #newBuilder()
+     */
+    @NotThreadSafe
+    public static class Builder
+    {
+        String goal;
+        String description;
+        String implementation;
+        String language;
+        String phase;
+        String executePhase;
+        String executeGoal;
+        String executeLifecycle;
+        String requiresDependencyResolution;
+        String requiresDependencyCollection;
+        Boolean requiresDirectInvocation;
+        Boolean requiresProject;
+        Boolean requiresReports;
+        Boolean requiresOnline;
+        Boolean aggregator;
+        Boolean inheritedByDefault;
+        Boolean threadSafe;
+        Boolean v4Api;
+        String instantiationStrategy;
+        String executionStrategy;
+        String since;
+        String deprecated;
+        String configurator;
+        String composer;
+        Collection<Parameter> parameters;
+        Dom configuration;
+        Collection<Requirement> requirements;
+
+        Builder( boolean withDefaults )
+        {
+            if ( withDefaults )
+            {
+                this.language = "java";
+                this.requiresDependencyResolution = "runtime";
+                this.requiresDirectInvocation = false;
+                this.requiresProject = true;
+                this.requiresReports = false;
+                this.requiresOnline = false;
+                this.aggregator = false;
+                this.inheritedByDefault = true;
+                this.threadSafe = false;
+                this.v4Api = false;
+                this.instantiationStrategy = "per-lookup";
+                this.executionStrategy = "once-per-session";
+            }
+        }
+
+        @Nonnull
+        public Builder goal( String goal )
+        {
+            this.goal = goal;
+            return this;
+        }
+
+        @Nonnull
+        public Builder description( String description )
+        {
+            this.description = description;
+            return this;
+        }
+
+        @Nonnull
+        public Builder implementation( String implementation )
+        {
+            this.implementation = implementation;
+            return this;
+        }
+
+        @Nonnull
+        public Builder language( String language )
+        {
+            this.language = language;
+            return this;
+        }
+
+        @Nonnull
+        public Builder phase( String phase )
+        {
+            this.phase = phase;
+            return this;
+        }
+
+        @Nonnull
+        public Builder executePhase( String executePhase )
+        {
+            this.executePhase = executePhase;
+            return this;
+        }
+
+        @Nonnull
+        public Builder executeGoal( String executeGoal )
+        {
+            this.executeGoal = executeGoal;
+            return this;
+        }
+
+        @Nonnull
+        public Builder executeLifecycle( String executeLifecycle )
+        {
+            this.executeLifecycle = executeLifecycle;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiresDependencyResolution( String 
requiresDependencyResolution )
+        {
+            this.requiresDependencyResolution = requiresDependencyResolution;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiresDependencyCollection( String 
requiresDependencyCollection )
+        {
+            this.requiresDependencyCollection = requiresDependencyCollection;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiresDirectInvocation( boolean 
requiresDirectInvocation )
+        {
+            this.requiresDirectInvocation = requiresDirectInvocation;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiresProject( boolean requiresProject )
+        {
+            this.requiresProject = requiresProject;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiresReports( boolean requiresReports )
+        {
+            this.requiresReports = requiresReports;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiresOnline( boolean requiresOnline )
+        {
+            this.requiresOnline = requiresOnline;
+            return this;
+        }
+
+        @Nonnull
+        public Builder aggregator( boolean aggregator )
+        {
+            this.aggregator = aggregator;
+            return this;
+        }
+
+        @Nonnull
+        public Builder inheritedByDefault( boolean inheritedByDefault )
+        {
+            this.inheritedByDefault = inheritedByDefault;
+            return this;
+        }
+
+        @Nonnull
+        public Builder threadSafe( boolean threadSafe )
+        {
+            this.threadSafe = threadSafe;
+            return this;
+        }
+
+        @Nonnull
+        public Builder v4Api( boolean v4Api )
+        {
+            this.v4Api = v4Api;
+            return this;
+        }
+
+        @Nonnull
+        public Builder instantiationStrategy( String instantiationStrategy )
+        {
+            this.instantiationStrategy = instantiationStrategy;
+            return this;
+        }
+
+        @Nonnull
+        public Builder executionStrategy( String executionStrategy )
+        {
+            this.executionStrategy = executionStrategy;
+            return this;
+        }
+
+        @Nonnull
+        public Builder since( String since )
+        {
+            this.since = since;
+            return this;
+        }
+
+        @Nonnull
+        public Builder deprecated( String deprecated )
+        {
+            this.deprecated = deprecated;
+            return this;
+        }
+
+        @Nonnull
+        public Builder configurator( String configurator )
+        {
+            this.configurator = configurator;
+            return this;
+        }
+
+        @Nonnull
+        public Builder composer( String composer )
+        {
+            this.composer = composer;
+            return this;
+        }
+
+        @Nonnull
+        public Builder parameters( Collection<Parameter> parameters )
+        {
+            this.parameters = parameters;
+            return this;
+        }
+
+        @Nonnull
+        public Builder configuration( Dom configuration )
+        {
+            this.configuration = configuration;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requirements( Collection<Requirement> requirements )
+        {
+            this.requirements = requirements;
+            return this;
+        }
+
+        @Nonnull
+        public MojoDescriptor build() throws DuplicateParameterException
+        {
+            MojoDescriptor mojoDescriptor = new MojoDescriptor();
+            mojoDescriptor.setGoal( goal );
+            mojoDescriptor.setDescription( description );
+            mojoDescriptor.setImplementation( implementation );
+            mojoDescriptor.setLanguage( language );
+            mojoDescriptor.setPhase( phase );
+            mojoDescriptor.setExecutePhase( executePhase );
+            mojoDescriptor.setExecuteGoal( executeGoal );
+            mojoDescriptor.setExecuteLifecycle( executeLifecycle );
+            mojoDescriptor.setDependencyResolutionRequired( 
requiresDependencyResolution );
+            mojoDescriptor.setDependencyCollectionRequired( 
requiresDependencyCollection );
+            mojoDescriptor.setDirectInvocationOnly( requiresDirectInvocation );
+            mojoDescriptor.setProjectRequired( requiresProject );
+            mojoDescriptor.setRequiresReports( requiresReports );
+            mojoDescriptor.setOnlineRequired( requiresOnline );
+            mojoDescriptor.setAggregator( aggregator );
+            mojoDescriptor.setInheritedByDefault( inheritedByDefault );
+            mojoDescriptor.setThreadSafe( threadSafe );
+            mojoDescriptor.setV4Api( v4Api );
+            mojoDescriptor.setInstantiationStrategy( instantiationStrategy );
+            mojoDescriptor.setExecutionStrategy( executionStrategy );
+            mojoDescriptor.setSince( since );
+            mojoDescriptor.setDeprecated( deprecated );
+            mojoDescriptor.setComponentConfigurator( configurator );
+            mojoDescriptor.setComponentComposer( composer );
+            if ( parameters != null )
+            {
+                mojoDescriptor.setParameters( parameters );
+            }
+            if ( configuration != null )
+            {
+                mojoDescriptor.setMojoConfiguration( new Xpp3Dom( 
configuration ) );
+            }
+            if ( requirements != null )
+            {
+                mojoDescriptor.setRequirements( requirements );
+            }
+            return mojoDescriptor;
+            
+        }
+    }
+
 }
diff --git 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
 
b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
deleted file mode 100644
index 14fd2f0ba..000000000
--- 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/Parameter.java
+++ /dev/null
@@ -1,207 +0,0 @@
-package org.apache.maven.plugin.descriptor;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author Jason van Zyl
- */
-public class Parameter
-    implements Cloneable
-{
-    private String alias;
-
-    private String name;
-
-    private String type;
-
-    private boolean required;
-
-    private boolean editable = true;
-
-    private String description;
-
-    private String expression;
-
-    private String deprecated;
-
-    private String defaultValue;
-
-    private String implementation;
-
-    private Requirement requirement;
-
-    private String since;
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    public String getName()
-    {
-        return name;
-    }
-
-    public void setName( String name )
-    {
-        this.name = name;
-    }
-
-    public String getType()
-    {
-        return type;
-    }
-
-    public void setType( String type )
-    {
-        this.type = type;
-    }
-
-    public boolean isRequired()
-    {
-        return required;
-    }
-
-    public void setRequired( boolean required )
-    {
-        this.required = required;
-    }
-
-    public String getDescription()
-    {
-        return description;
-    }
-
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
-
-    public String getExpression()
-    {
-        return expression;
-    }
-
-    public void setExpression( String expression )
-    {
-        this.expression = expression;
-    }
-
-    public String getDeprecated()
-    {
-        return deprecated;
-    }
-
-    public void setDeprecated( String deprecated )
-    {
-        this.deprecated = deprecated;
-    }
-
-    public int hashCode()
-    {
-        return name.hashCode();
-    }
-
-    public boolean equals( Object other )
-    {
-        return ( other instanceof Parameter ) && getName().equals( ( 
(Parameter) other ).getName() );
-    }
-
-    public String getAlias()
-    {
-        return alias;
-    }
-
-    public void setAlias( String alias )
-    {
-        this.alias = alias;
-    }
-
-    public boolean isEditable()
-    {
-        return editable;
-    }
-
-    public void setEditable( boolean editable )
-    {
-        this.editable = editable;
-    }
-
-    public void setDefaultValue( String defaultValue )
-    {
-        this.defaultValue = defaultValue;
-    }
-
-    public String getDefaultValue()
-    {
-        return defaultValue;
-    }
-
-    public String toString()
-    {
-        return "Mojo parameter [name: '" + getName() + "'; alias: '" + 
getAlias() + "']";
-    }
-
-    public Requirement getRequirement()
-    {
-        return requirement;
-    }
-
-    public void setRequirement( Requirement requirement )
-    {
-        this.requirement = requirement;
-    }
-
-    public String getImplementation()
-    {
-        return implementation;
-    }
-
-    public void setImplementation( String implementation )
-    {
-        this.implementation = implementation;
-    }
-
-    public String getSince()
-    {
-        return since;
-    }
-
-    public void setSince( String since )
-    {
-        this.since = since;
-    }
-
-    /**
-     * Creates a shallow copy of this parameter.
-     */
-    @Override
-    public Parameter clone()
-    {
-        try
-        {
-            return (Parameter) super.clone();
-        }
-        catch ( CloneNotSupportedException e )
-        {
-            throw new UnsupportedOperationException( e );
-        }
-    }
-
-}
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 8c799419c..ccc2b9f0a 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
@@ -19,6 +19,9 @@ package org.apache.maven.plugin.descriptor;
  * under the License.
  */
 
+
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.NotThreadSafe;
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.ArtifactUtils;
 import org.apache.maven.model.Plugin;
@@ -26,6 +29,7 @@ import org.apache.maven.plugin.lifecycle.Lifecycle;
 import org.apache.maven.plugin.lifecycle.LifecycleConfiguration;
 import org.apache.maven.plugin.lifecycle.io.xpp3.LifecycleMappingsXpp3Reader;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.component.repository.ComponentDependency;
 import org.codehaus.plexus.component.repository.ComponentSetDescriptor;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -37,13 +41,18 @@ import java.io.InputStream;
 import java.io.Reader;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
+ * This file is not generated from the underlying Modello model as it needs to 
extend {@link ComponentSetDescriptor}
+ * which is not based on a model.
+ * 
  * @author Jason van Zyl
  */
 public class PluginDescriptor
@@ -88,6 +97,7 @@ public class PluginDescriptor
 
     private Map<String, Lifecycle> lifecycleMappings;
 
+    private List<Dependency> dependencies;
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -448,7 +458,7 @@ public class PluginDescriptor
         }
     }
 
-    public void addMojos( List<MojoDescriptor> mojos )
+    public void setMojos( Collection<MojoDescriptor> mojos )
         throws DuplicateMojoDescriptorException
     {
         for ( MojoDescriptor mojoDescriptor : mojos )
@@ -458,4 +468,208 @@ public class PluginDescriptor
 
     }
 
+
+    public void setModelEncoding( String inputEncoding )
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setDependencies2( Collection<Dependency> dependencies2 )
+    {
+        dependencies2.stream().map( Dependency::toComponentDependency 
).forEach( this::addDependency );
+    }
+
+    public final List<ComponentDependency> getDependencies2()
+    {
+        return dependencies.stream().map( Dependency::toComponentDependency 
).collect( Collectors.toList() );
+    }
+
+
+    /**
+     * Creates a new PluginDescriptor instance.
+     * Equivalent to {@code newInstance( true )}.
+     * @throws DuplicateMojoDescriptorException 
+     * @see #newInstance(boolean)
+     */
+    @Nonnull
+    public static PluginDescriptor newInstance() throws 
DuplicateMojoDescriptorException
+    {
+        return newInstance( true );
+    }
+
+    /**
+     * Creates a new PluginDescriptor instance using default values or not.
+     * Equivalent to {@code newBuilder( withDefaults ).build()}.
+     * @throws DuplicateMojoDescriptorException 
+     */
+    @Nonnull
+    public static PluginDescriptor newInstance( boolean withDefaults ) throws 
DuplicateMojoDescriptorException
+    {
+        return newBuilder( withDefaults ).build();
+    }
+
+    /**
+     * Creates a new PluginDescriptor builder instance.
+     * Equivalent to {@code newBuilder( true )}.
+     * @see #newBuilder(boolean)
+     */
+    @Nonnull
+    public static Builder newBuilder()
+    {
+        return newBuilder( true );
+    }
+
+    /**
+     * Creates a new PluginDescriptor builder instance using default values or 
not.
+     */
+    @Nonnull
+    public static Builder newBuilder( boolean withDefaults )
+    {
+        return new Builder( withDefaults );
+    }
+
+
+    /**
+     * Builder class used to create PluginDescriptor instances.
+     * @see #with()
+     * @see #newBuilder()
+     */
+    @NotThreadSafe
+    public static class Builder
+    {
+        String modelEncoding;
+        String name;
+        String description;
+        String groupId;
+        String artifactId;
+        String version;
+        String goalPrefix;
+        Boolean isolatedRealm;
+        Boolean inheritedByDefault;
+        String requiredJavaVersion;
+        String requiredMavenVersion;
+        Collection<MojoDescriptor> mojos;
+        Collection<Dependency> dependencies;
+
+        Builder( boolean withDefaults )
+        {
+            if ( withDefaults )
+            {
+                this.isolatedRealm = false;
+                this.inheritedByDefault = true;
+            }
+        }
+
+        @Nonnull
+        public Builder modelEncoding( String modelEncoding )
+        {
+            this.modelEncoding = modelEncoding;
+            return this;
+        }
+
+        @Nonnull
+        public Builder name( String name )
+        {
+            this.name = name;
+            return this;
+        }
+
+        @Nonnull
+        public Builder description( String description )
+        {
+            this.description = description;
+            return this;
+        }
+
+        @Nonnull
+        public Builder groupId( String groupId )
+        {
+            this.groupId = groupId;
+            return this;
+        }
+
+        @Nonnull
+        public Builder artifactId( String artifactId )
+        {
+            this.artifactId = artifactId;
+            return this;
+        }
+
+        @Nonnull
+        public Builder version( String version )
+        {
+            this.version = version;
+            return this;
+        }
+
+        @Nonnull
+        public Builder goalPrefix( String goalPrefix )
+        {
+            this.goalPrefix = goalPrefix;
+            return this;
+        }
+
+        @Nonnull
+        public Builder isolatedRealm( boolean isolatedRealm )
+        {
+            this.isolatedRealm = isolatedRealm;
+            return this;
+        }
+
+        @Nonnull
+        public Builder inheritedByDefault( boolean inheritedByDefault )
+        {
+            this.inheritedByDefault = inheritedByDefault;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiredJavaVersion( String requiredJavaVersion )
+        {
+            this.requiredJavaVersion = requiredJavaVersion;
+            return this;
+        }
+
+        @Nonnull
+        public Builder requiredMavenVersion( String requiredMavenVersion )
+        {
+            this.requiredMavenVersion = requiredMavenVersion;
+            return this;
+        }
+
+        @Nonnull
+        public Builder mojos( Collection<MojoDescriptor> mojos )
+        {
+            this.mojos = mojos;
+            return this;
+        }
+
+        @Nonnull
+        public Builder dependencies( Collection<Dependency> dependencies2 )
+        {
+            this.dependencies = dependencies2;
+            return this;
+        }
+
+
+        @Nonnull
+        public PluginDescriptor build() throws DuplicateMojoDescriptorException
+        {
+            PluginDescriptor pluginDescriptor = new PluginDescriptor();
+            pluginDescriptor.setName( name );
+            pluginDescriptor.setDescription( description );
+            pluginDescriptor.setGroupId( groupId );
+            pluginDescriptor.setArtifactId( artifactId );
+            pluginDescriptor.setVersion( version );
+            pluginDescriptor.setGoalPrefix( goalPrefix );
+            pluginDescriptor.setIsolatedRealm( isolatedRealm );
+            pluginDescriptor.setInheritedByDefault( inheritedByDefault );
+            pluginDescriptor.setRequiredJavaVersion( requiredJavaVersion );
+            pluginDescriptor.setRequiredMavenVersion( requiredMavenVersion );
+            pluginDescriptor.setMojos( mojos );
+            pluginDescriptor.setDependencies2( dependencies );
+            return pluginDescriptor;
+        }
+    }
 }
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 98021fa0c..a960ab192 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
@@ -21,21 +21,16 @@ package org.apache.maven.plugin.descriptor;
 
 import java.io.IOException;
 import java.io.Reader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-import org.apache.maven.internal.xml.XmlPlexusConfiguration;
-import org.apache.maven.internal.xml.Xpp3DomBuilder;
-import org.codehaus.plexus.component.repository.ComponentDependency;
-import org.codehaus.plexus.component.repository.ComponentRequirement;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
+
+import org.apache.maven.plugin.descriptor.io.xpp3.PluginDescriptorXpp3Reader;
 import org.codehaus.plexus.configuration.PlexusConfigurationException;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 /**
+ * @deprecated Use {@link PluginDescriptorXpp3Reader} instead.
  * @author Jason van Zyl
  */
+@Deprecated
 public class PluginDescriptorBuilder
 {
     public PluginDescriptor build( Reader reader )
@@ -47,140 +42,17 @@ public class PluginDescriptorBuilder
     public PluginDescriptor build( Reader reader, String source )
         throws PlexusConfigurationException
     {
-        return build( source, buildConfiguration( reader ) );
-    }
-
-    private PluginDescriptor build( String source, PlexusConfiguration c )
-        throws PlexusConfigurationException
-    {
-        PluginDescriptor pluginDescriptor = new PluginDescriptor();
-
-        pluginDescriptor.setSource( source );
-        pluginDescriptor.setGroupId( extractGroupId( c ) );
-        pluginDescriptor.setArtifactId( extractArtifactId( c ) );
-        pluginDescriptor.setVersion( extractVersion( c ) );
-        pluginDescriptor.setGoalPrefix( extractGoalPrefix( c ) );
-
-        pluginDescriptor.setName( extractName( c ) );
-        pluginDescriptor.setDescription( extractDescription( c ) );
-
-        pluginDescriptor.setIsolatedRealm( extractIsolatedRealm( c ) );
-        pluginDescriptor.setInheritedByDefault( extractInheritedByDefault( c ) 
);
-        pluginDescriptor.setRequiredJavaVersion( extractRequiredJavaVersion( c 
).orElse( null ) );
-        pluginDescriptor.setRequiredMavenVersion( extractRequiredMavenVersion( 
c ).orElse( 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 )
-        {
-            mojos.add( buildComponentDescriptor( component, pluginDescriptor ) 
);
-
-        }
-        return mojos;
-    }
-
-    private boolean extractInheritedByDefault( PlexusConfiguration c )
-    {
-        String inheritedByDefault = c.getChild( "inheritedByDefault" 
).getValue();
-
-        if ( inheritedByDefault != null )
-        {
-            return Boolean.parseBoolean( inheritedByDefault );
-        }
-        return false;
-    }
-
-    private boolean extractIsolatedRealm( PlexusConfiguration c )
-    {
-        String isolatedRealm = c.getChild( "isolatedRealm" ).getValue();
-
-        if ( isolatedRealm != null )
+        try
         {
-            return Boolean.parseBoolean( isolatedRealm );
+            return new PluginDescriptorXpp3Reader().read( reader, false );
         }
-        return false;
-    }
-
-    private Optional<String> extractRequiredJavaVersion( PlexusConfiguration c 
)
-    {
-        return Optional.ofNullable( c.getChild( "requiredJavaVersion" ) ).map( 
PlexusConfiguration::getValue );
-    }
-
-    private Optional<String> extractRequiredMavenVersion( PlexusConfiguration 
c )
-    {
-        return Optional.ofNullable( c.getChild( "requiredMavenVersion" ) 
).map( PlexusConfiguration::getValue );
-    }
-
-    private List<ComponentDependency> extractComponentDependencies( 
PlexusConfiguration c )
-    {
-
-        PlexusConfiguration[] dependencyConfigurations = c.getChild( 
"dependencies" ).getChildren( "dependency" );
-
-        List<ComponentDependency> dependencies = new ArrayList<>();
-
-        for ( PlexusConfiguration d : dependencyConfigurations )
+        catch ( IOException | XmlPullParserException e )
         {
-            dependencies.add( extractComponentDependency( d ) );
+            throw new PlexusConfigurationException( "Error reading plugin 
descriptor", e );
         }
-        return dependencies;
-    }
-
-    private ComponentDependency extractComponentDependency( 
PlexusConfiguration d )
-    {
-        ComponentDependency cd = new ComponentDependency();
-
-        cd.setArtifactId( extractArtifactId( d ) );
-
-        cd.setGroupId( extractGroupId( d ) );
-
-        cd.setType( d.getChild( "type" ).getValue() );
-
-        cd.setVersion( extractVersion( d ) );
-        return cd;
     }
 
+/*
     @SuppressWarnings( "checkstyle:methodlength" )
     public MojoDescriptor buildComponentDescriptor( PlexusConfiguration c, 
PluginDescriptor pluginDescriptor )
         throws PlexusConfigurationException
@@ -427,5 +299,5 @@ public class PluginDescriptorBuilder
         {
             throw new PlexusConfigurationException( e.getMessage(), e );
         }
-    }
+    }*/
 }
diff --git 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/Requirement.java
 
b/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/Requirement.java
deleted file mode 100644
index 1526b039e..000000000
--- 
a/maven-plugin-api/src/main/java/org/apache/maven/plugin/descriptor/Requirement.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.maven.plugin.descriptor;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Describes a component requirement.
- *
- * @author <a href="mailto:br...@apache.org";>Brett Porter</a>
- */
-public class Requirement
-    implements Cloneable
-{
-    private final String role;
-
-    private final String roleHint;
-
-    public Requirement( String role )
-    {
-        this.role = role;
-        this.roleHint = null;
-    }
-
-    public Requirement( String role, String roleHint )
-    {
-        this.role = role;
-        this.roleHint = roleHint;
-    }
-
-    public String getRole()
-    {
-        return role;
-    }
-
-    public String getRoleHint()
-    {
-        return roleHint;
-    }
-
-    /**
-     * Creates a shallow copy of this requirement.
-     */
-    @Override
-    public Requirement clone()
-    {
-        try
-        {
-            return (Requirement) super.clone();
-        }
-        catch ( CloneNotSupportedException e )
-        {
-            throw new UnsupportedOperationException( e );
-        }
-    }
-
-}
diff --git a/maven-plugin-api/src/main/mdo/plugin.mdo 
b/maven-plugin-api/src/main/mdo/plugin.mdo
index ddb2fd62a..971d433c0 100644
--- a/maven-plugin-api/src/main/mdo/plugin.mdo
+++ b/maven-plugin-api/src/main/mdo/plugin.mdo
@@ -34,7 +34,7 @@ under the License.
   <defaults>
     <default>
       <key>package</key>
-      <value>plugin descriptor XML documentation (no java 
generation)</value><!-- intentionally non-buildable value -->
+      <value>org.apache.maven.plugin.descriptor</value><!-- intentionally 
non-buildable value -->
     </default>
   </defaults>
   <classes>
@@ -240,7 +240,7 @@ under the License.
         </field>
         <field>
           <name>requiresReports</name>
-          <version>1.0.0</version><!-- no longer part of 1.1.0 -->
+          <version>1.0.0+</version><!-- no longer part of 1.1.0 -->
           <type>boolean</type>
           <description>Flags this Mojo to require running inside of a reports 
context. Unsupported since Maven 3.0.</description>
           <defaultValue>false</defaultValue>
@@ -370,7 +370,7 @@ under the License.
     <class xdoc.anchorName="parameter">
       <name>Parameter</name>
       <version>1.0.0+</version>
-      <description>A phase mapping definition.</description>
+      <description>A parameter definition.</description>
       <!-- see o.a.m.plugin.descriptor.Parameter -->
       <fields>
         <field>
@@ -455,6 +455,37 @@ under the License.
           ]]></description>
         </field>
       </fields>
+      <codeSegments>
+        <codeSegment>
+          <version>1.1.0+</version> <!--previously the model has been 
handcrafted -->
+          <comment>Add setters/getters for expression and default value coming 
from the mojo's configuration</comment>
+          <code><![CDATA[
+    /* getters exposing information originally comfing from the mojo's 
configuration */
+    private String expression;
+    private String defaultValue;
+
+    public String getExpression()
+    {
+        return expression;
+    }
+
+    public void setExpression( String expression )
+    {
+        this.expression = expression;
+    }
+
+    public void setDefaultValue( String defaultValue )
+    {
+        this.defaultValue = defaultValue;
+    }
+
+    public String getDefaultValue()
+    {
+        return defaultValue;
+    }]]>
+          </code>
+        </codeSegment>
+      </codeSegments>
     </class>
 
     <class>
@@ -512,6 +543,26 @@ under the License.
           <description>The field name which has this requirement.</description>
         </field>
       </fields>
+      <codeSegments>
+        <codeSegment>
+          <version>1.1.0+</version> <!--previously the model has been 
handcrafted -->
+          <comment>Conversion to Plexus Component Requirement</comment>
+          <code><![CDATA[
+    /**
+     * Converts the given requirement to a Plexus Component Requirement
+     */
+    org.codehaus.plexus.component.repository.ComponentRequirement 
toComponentRequirement()
+    {
+        org.codehaus.plexus.component.repository.ComponentRequirement 
componentRequirement
+            = new 
org.codehaus.plexus.component.repository.ComponentRequirement();
+        componentRequirement.setRole( role );
+        componentRequirement.setRoleHint( roleHint );
+        componentRequirement.setFieldName( fieldName );
+        return componentRequirement;
+    }]]>
+          </code>
+        </codeSegment>
+      </codeSegments>
     </class>
 
     <class xdoc.anchorName="dependency">
@@ -547,6 +598,27 @@ under the License.
           <description>The type of dependency.</description>
         </field>
       </fields>
+      <codeSegments>
+        <codeSegment>
+          <version>1.1.0+</version> <!--previously the model has been 
handcrafted -->
+          <comment>Conversion to Plexus Component Dependency</comment>
+          <code><![CDATA[
+    /**
+     * Converts the given dependency to a Plexus Component Dependency
+     */
+    org.codehaus.plexus.component.repository.ComponentDependency 
toComponentDependency()
+    {
+        org.codehaus.plexus.component.repository.ComponentDependency 
componentDependency
+            = new 
org.codehaus.plexus.component.repository.ComponentDependency();
+        componentDependency.setGroupId( groupId );
+        componentDependency.setArtifactId( artifactId );
+        componentDependency.setVersion( version );
+        componentDependency.setType( type );
+        return componentDependency;
+    }]]>
+          </code>
+        </codeSegment>
+      </codeSegments>
     </class>
   </classes>
 </model>
diff --git 
a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/MojoDescriptorTest.java
 
b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/MojoDescriptorTest.java
index 0aec7d372..4f2c94550 100644
--- 
a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/MojoDescriptorTest.java
+++ 
b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/MojoDescriptorTest.java
@@ -32,18 +32,14 @@ public class MojoDescriptorTest
     public void getParameterMap() throws DuplicateParameterException
     {
         MojoDescriptor mojoDescriptor = new MojoDescriptor();
-        Parameter param1 = new Parameter();
-        param1.setName( "param1" );
-        param1.setDefaultValue( "value1" );
+        Parameter param1 = Parameter.newBuilder().name( "param1" ).build();
         mojoDescriptor.addParameter( param1 );
 
         assertEquals( 1, mojoDescriptor.getParameters().size() );
 
         assertEquals( mojoDescriptor.getParameters().size(), 
mojoDescriptor.getParameterMap().size() );
 
-        Parameter param2 = new Parameter();
-        param2.setName( "param2" );
-        param2.setDefaultValue( "value2" );
+        Parameter param2 = Parameter.newBuilder().name( "param2" ).build();
         mojoDescriptor.addParameter( param2 );
 
         assertEquals( 2, mojoDescriptor.getParameters().size() );
diff --git 
a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java
 
b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java
index 88d249069..17fe8b67d 100644
--- 
a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java
+++ 
b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java
@@ -131,7 +131,7 @@ public class PluginDescriptorBuilderTest
         md = pd.getMojos().get( 1 );
 
         assertEquals( "war", md.getGoal() );
-        assertNull( md.getDependencyResolutionRequired() );
+        assertEquals( "runtime", md.getDependencyResolutionRequired() ); // 
default
         assertNull( md.getDependencyCollectionRequired() );
         assertTrue( md.isThreadSafe() );
     }
diff --git 
a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java
 
b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorXpp3ReaderTest.java
similarity index 90%
copy from 
maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java
copy to 
maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorXpp3ReaderTest.java
index 88d249069..3e6bfc463 100644
--- 
a/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorBuilderTest.java
+++ 
b/maven-plugin-api/src/test/java/org/apache/maven/plugin/descriptor/PluginDescriptorXpp3ReaderTest.java
@@ -20,13 +20,14 @@ package org.apache.maven.plugin.descriptor;
  */
 
 import java.io.IOException;
-import java.io.Reader;
+import java.io.InputStream;
+import java.util.Objects;
 
 import org.codehaus.plexus.component.repository.ComponentDependency;
 import org.codehaus.plexus.component.repository.ComponentRequirement;
 import org.codehaus.plexus.configuration.PlexusConfiguration;
 import org.codehaus.plexus.configuration.PlexusConfigurationException;
-import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -40,15 +41,16 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
  *
  * @author Benjamin Bentmann
  */
-public class PluginDescriptorBuilderTest
+public class PluginDescriptorXpp3ReaderTest
 {
 
     private PluginDescriptor build( String resource )
-        throws IOException, PlexusConfigurationException
+        throws IOException, PlexusConfigurationException, 
XmlPullParserException
     {
-        Reader reader = ReaderFactory.newXmlReader( 
getClass().getResourceAsStream( resource ) );
-
-        return new PluginDescriptorBuilder().build( reader );
+        try (InputStream input = Objects.requireNonNull( 
getClass().getResourceAsStream( resource ) ) )
+        {
+            return new 
org.apache.maven.plugin.descriptor.io.xpp3.PluginDescriptorXpp3Reader().read( 
input );
+        }
     }
 
     @Test
@@ -131,7 +133,7 @@ public class PluginDescriptorBuilderTest
         md = pd.getMojos().get( 1 );
 
         assertEquals( "war", md.getGoal() );
-        assertNull( md.getDependencyResolutionRequired() );
+        assertEquals( "runtime", md.getDependencyResolutionRequired() ); // 
default
         assertNull( md.getDependencyCollectionRequired() );
         assertTrue( md.isThreadSafe() );
     }

Reply via email to