You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-commits@maven.apache.org by sv...@apache.org on 2022/10/26 12:46:45 UTC

svn commit: r1904852 - in /maven/website/content: guides/mini/guide-configuring-plugins.html maven-site-1.0-site.jar

Author: svn-site-role
Date: Wed Oct 26 12:46:44 2022
New Revision: 1904852

Log:
Site checkin for project Apache Maven Site

Modified:
    maven/website/content/guides/mini/guide-configuring-plugins.html
    maven/website/content/maven-site-1.0-site.jar

Modified: maven/website/content/guides/mini/guide-configuring-plugins.html
==============================================================================
--- maven/website/content/guides/mini/guide-configuring-plugins.html (original)
+++ maven/website/content/guides/mini/guide-configuring-plugins.html Wed Oct 26 12:46:44 2022
@@ -329,7 +329,7 @@ public class MyQueryMojo
     extends AbstractMojo
 {
     @Parameter(property = "animals")
-    private List animals;
+    private List<String> animals;
 
     public void execute()
         throws MojoExecutionException
@@ -357,11 +357,12 @@ public class MyQueryMojo
   </build>
   ...
 &lt;/project&gt;</pre></div>
-<p>Where each of the animals listed would be entries in the <code>animals</code> field. Unlike arrays, collections have no specific component type. In order to derive the type of a list item, the following strategy is used:</p>
+<p>Where each of the animals listed would be entries in the <code>animals</code> field. Unlike arrays, collections do not necessarily have a specific component type. In order to derive the type of a collection item, the following strategy is used:</p>
 <ol style="list-style-type: decimal">
-<li>If the XML element contains an <code>implementation</code> hint attribute, that is used</li>
-<li>If the XML tag contains a <code>.</code>, try that as a fully qualified class name</li>
-<li>Try the XML tag (with capitalized first letter) as a class in the same package as the mojo/object being configured</li>
+<li>If the XML element contains an <code>implementation</code> hint attribute, try to load the class with the given fully qualified class name from the attribute value</li>
+<li>If the XML element contains a <code>.</code>, try to load the class with the fully qualified class name given in the element name</li>
+<li>Try the XML element name (with capitalized first letter) as a class in the same package as the mojo/object being configured</li>
+<li>Use the parameter type information from either <a class="externalLink" href="https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Field.html#getGenericType()"><code>Field.getGenericType()</code></a> or <a class="externalLink" href="https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#getGenericParameterTypes()"><code>Method.getGenericParameterTypes()</code></a></li>
 <li>If the element has no children, assume its type is <code>String</code>. Otherwise, the configuration will fail.</li></ol>
 <p>Since Maven 3.3.9 (<a class="externalLink" href="https://issues.apache.org/jira/browse/MNG-5440">MNG-5440</a>), you can list individual items alternatively as comma-separated list in the XML value of animals directly. This approach is also used if configuring collection/array parameters via command line The following example is equivalent to the example above:</p>
 <div class="source"><pre class="prettyprint linenums">&lt;project&gt;
@@ -384,7 +385,7 @@ public class MyQueryMojo
 <p>In the same way, you could define maps like the following:</p>
 <div class="source"><pre class="prettyprint linenums">...
     @Parameter
-    private Map myMap;
+    private Map&lt;String,String&gt; myMap;
 ...</pre></div>
 <div class="source"><pre class="prettyprint linenums">...
   &lt;configuration&gt;
@@ -394,7 +395,8 @@ public class MyQueryMojo
     &lt;/myMap&gt;
   &lt;/configuration&gt;
 ...</pre></div>
-<p>In contrast to value objects and collections/arrays there is no string coercion defined for maps, i.e. you cannot give parameters of those type via CLI argument. </p></section><section>
+<p>Unlike Collections the value type for Maps is always derived from the parameter type information from either <a class="externalLink" href="https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Field.html#getGenericType()"><code>Field.getGenericType()</code></a> or <a class="externalLink" href="https://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#getGenericParameterTypes()"><code>Method.getGenericParameterTypes()</code></a>. It falls back to <code>String</code>. The key type must always be <code>String</code>.</p>
+<p>In contrast to value objects and collections/arrays there is no string coercion defined for maps, i.e. you cannot give parameters of that type via CLI argument. </p></section><section>
 <h5><a name="Mapping_Properties">Mapping Properties</a></h5>
 <p>Properties should be defined like the following:</p>
 <div class="source"><pre class="prettyprint linenums">...

Modified: maven/website/content/maven-site-1.0-site.jar
==============================================================================
Binary files - no diff available.