View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   //  Generated by Modello Velocity from model.vm
3   //  template, any modifications will be overwritten.
4   // ==============================================================
5   package org.apache.maven.api.plugin.descriptor;
6   
7   import java.io.Serializable;
8   import java.util.ArrayList;
9   import java.util.Collection;
10  import java.util.Collections;
11  import java.util.HashMap;
12  import java.util.List;
13  import java.util.Map;
14  import java.util.Set;
15  import org.apache.maven.api.annotations.Experimental;
16  import org.apache.maven.api.annotations.Generated;
17  import org.apache.maven.api.annotations.Immutable;
18  import org.apache.maven.api.annotations.Nonnull;
19  import org.apache.maven.api.annotations.NotThreadSafe;
20  import org.apache.maven.api.annotations.ThreadSafe;
21  
22  /**
23   * Root element of the {@code plugin.xml} file.
24   */
25  @Experimental
26  @Generated @ThreadSafe @Immutable
27  public class PluginDescriptor
28      implements Serializable
29  {
30      final String namespaceUri;
31      final String modelEncoding;
32      /**
33       * Name of the plugin.
34       */
35      final String name;
36      /**
37       * Description of the plugin.
38       */
39      final String description;
40      /**
41       * The group id of the plugin.
42       */
43      final String groupId;
44      /**
45       * The artifact id of the plugin.
46       */
47      final String artifactId;
48      /**
49       * The version of the plugin.
50       */
51      final String version;
52      /**
53       * 
54       */
55      final String goalPrefix;
56      /**
57       * 
58       */
59      final boolean isolatedRealm;
60      /**
61       * 
62       */
63      final boolean inheritedByDefault;
64      /**
65       * A version range which specifies the supported Java versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required.
66       * @since Maven 4.0.0-alpha-3
67       */
68      final String requiredJavaVersion;
69      /**
70       * A version range which specifies the supported Maven versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required. This value takes precedence over the POMs Maven prerequisite.
71       * @since Maven 4.0.0-alpha-3
72       */
73      final String requiredMavenVersion;
74      /**
75       * Description of each Mojo provided by the plugin.
76       */
77      final List<MojoDescriptor> mojos;
78  
79      /**
80        * Constructor for this class, to be called from its subclasses and {@link Builder}.
81        * @see Builder#build()
82        */
83      protected PluginDescriptor(Builder builder) {
84          this.namespaceUri = builder.namespaceUri != null ? builder.namespaceUri : (builder.base != null ? builder.base.namespaceUri : null);
85          this.modelEncoding = builder.modelEncoding != null ? builder.modelEncoding : (builder.base != null ? builder.base.modelEncoding :  "UTF-8");
86          this.name = builder.name != null ? builder.name : (builder.base != null ? builder.base.name : null);
87          this.description = builder.description != null ? builder.description : (builder.base != null ? builder.base.description : null);
88          this.groupId = builder.groupId != null ? builder.groupId : (builder.base != null ? builder.base.groupId : null);
89          this.artifactId = builder.artifactId != null ? builder.artifactId : (builder.base != null ? builder.base.artifactId : null);
90          this.version = builder.version != null ? builder.version : (builder.base != null ? builder.base.version : null);
91          this.goalPrefix = builder.goalPrefix != null ? builder.goalPrefix : (builder.base != null ? builder.base.goalPrefix : null);
92          this.isolatedRealm = builder.isolatedRealm != null ? builder.isolatedRealm : (builder.base != null ? builder.base.isolatedRealm : false);
93          this.inheritedByDefault = builder.inheritedByDefault != null ? builder.inheritedByDefault : (builder.base != null ? builder.base.inheritedByDefault : true);
94          this.requiredJavaVersion = builder.requiredJavaVersion != null ? builder.requiredJavaVersion : (builder.base != null ? builder.base.requiredJavaVersion : null);
95          this.requiredMavenVersion = builder.requiredMavenVersion != null ? builder.requiredMavenVersion : (builder.base != null ? builder.base.requiredMavenVersion : null);
96          this.mojos = ImmutableCollections.copy(builder.mojos != null ? builder.mojos : (builder.base != null ? builder.base.mojos : null));
97      }
98  
99      public String getNamespaceUri() {
100         return namespaceUri;
101     }
102 
103     public String getModelEncoding() {
104         return modelEncoding;
105     }
106 
107     /**
108      * Name of the plugin.
109      *
110      * @return a {@code String}
111      */
112     public String getName() {
113         return this.name;
114     }
115 
116     /**
117      * Description of the plugin.
118      *
119      * @return a {@code String}
120      */
121     public String getDescription() {
122         return this.description;
123     }
124 
125     /**
126      * The group id of the plugin.
127      *
128      * @return a {@code String}
129      */
130     public String getGroupId() {
131         return this.groupId;
132     }
133 
134     /**
135      * The artifact id of the plugin.
136      *
137      * @return a {@code String}
138      */
139     public String getArtifactId() {
140         return this.artifactId;
141     }
142 
143     /**
144      * The version of the plugin.
145      *
146      * @return a {@code String}
147      */
148     public String getVersion() {
149         return this.version;
150     }
151 
152     /**
153      * 
154      *
155      * @return a {@code String}
156      */
157     public String getGoalPrefix() {
158         return this.goalPrefix;
159     }
160 
161     /**
162      * 
163      *
164      * @return a {@code boolean}
165      */
166     public boolean isIsolatedRealm() {
167         return this.isolatedRealm;
168     }
169 
170     /**
171      * 
172      *
173      * @return a {@code boolean}
174      */
175     public boolean isInheritedByDefault() {
176         return this.inheritedByDefault;
177     }
178 
179     /**
180      * A version range which specifies the supported Java versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required.
181      * @since Maven 4.0.0-alpha-3
182      *
183      * @return a {@code String}
184      */
185     public String getRequiredJavaVersion() {
186         return this.requiredJavaVersion;
187     }
188 
189     /**
190      * A version range which specifies the supported Maven versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required. This value takes precedence over the POMs Maven prerequisite.
191      * @since Maven 4.0.0-alpha-3
192      *
193      * @return a {@code String}
194      */
195     public String getRequiredMavenVersion() {
196         return this.requiredMavenVersion;
197     }
198 
199     /**
200      * Description of each Mojo provided by the plugin.
201      *
202      * @return a {@code List<MojoDescriptor>}
203      */
204     @Nonnull
205     public List<MojoDescriptor> getMojos() {
206         return this.mojos;
207     }
208 
209     /**
210      * Creates a new builder with this object as the basis.
211      *
212      * @return a {@code Builder}
213      */
214     @Nonnull
215     public Builder with() {
216         return newBuilder(this);
217     }
218     /**
219      * Creates a new {@code PluginDescriptor} instance using the specified name.
220      *
221      * @param name the new {@code String} to use
222      * @return a {@code PluginDescriptor} with the specified name
223      */
224     @Nonnull
225     public PluginDescriptor withName(String name) {
226         return newBuilder(this, true).name(name).build();
227     }
228     /**
229      * Creates a new {@code PluginDescriptor} instance using the specified description.
230      *
231      * @param description the new {@code String} to use
232      * @return a {@code PluginDescriptor} with the specified description
233      */
234     @Nonnull
235     public PluginDescriptor withDescription(String description) {
236         return newBuilder(this, true).description(description).build();
237     }
238     /**
239      * Creates a new {@code PluginDescriptor} instance using the specified groupId.
240      *
241      * @param groupId the new {@code String} to use
242      * @return a {@code PluginDescriptor} with the specified groupId
243      */
244     @Nonnull
245     public PluginDescriptor withGroupId(String groupId) {
246         return newBuilder(this, true).groupId(groupId).build();
247     }
248     /**
249      * Creates a new {@code PluginDescriptor} instance using the specified artifactId.
250      *
251      * @param artifactId the new {@code String} to use
252      * @return a {@code PluginDescriptor} with the specified artifactId
253      */
254     @Nonnull
255     public PluginDescriptor withArtifactId(String artifactId) {
256         return newBuilder(this, true).artifactId(artifactId).build();
257     }
258     /**
259      * Creates a new {@code PluginDescriptor} instance using the specified version.
260      *
261      * @param version the new {@code String} to use
262      * @return a {@code PluginDescriptor} with the specified version
263      */
264     @Nonnull
265     public PluginDescriptor withVersion(String version) {
266         return newBuilder(this, true).version(version).build();
267     }
268     /**
269      * Creates a new {@code PluginDescriptor} instance using the specified goalPrefix.
270      *
271      * @param goalPrefix the new {@code String} to use
272      * @return a {@code PluginDescriptor} with the specified goalPrefix
273      */
274     @Nonnull
275     public PluginDescriptor withGoalPrefix(String goalPrefix) {
276         return newBuilder(this, true).goalPrefix(goalPrefix).build();
277     }
278     /**
279      * Creates a new {@code PluginDescriptor} instance using the specified isolatedRealm.
280      *
281      * @param isolatedRealm the new {@code boolean} to use
282      * @return a {@code PluginDescriptor} with the specified isolatedRealm
283      */
284     @Nonnull
285     public PluginDescriptor withIsolatedRealm(boolean isolatedRealm) {
286         return newBuilder(this, true).isolatedRealm(isolatedRealm).build();
287     }
288     /**
289      * Creates a new {@code PluginDescriptor} instance using the specified inheritedByDefault.
290      *
291      * @param inheritedByDefault the new {@code boolean} to use
292      * @return a {@code PluginDescriptor} with the specified inheritedByDefault
293      */
294     @Nonnull
295     public PluginDescriptor withInheritedByDefault(boolean inheritedByDefault) {
296         return newBuilder(this, true).inheritedByDefault(inheritedByDefault).build();
297     }
298     /**
299      * Creates a new {@code PluginDescriptor} instance using the specified requiredJavaVersion.
300      *
301      * @param requiredJavaVersion the new {@code String} to use
302      * @return a {@code PluginDescriptor} with the specified requiredJavaVersion
303      */
304     @Nonnull
305     public PluginDescriptor withRequiredJavaVersion(String requiredJavaVersion) {
306         return newBuilder(this, true).requiredJavaVersion(requiredJavaVersion).build();
307     }
308     /**
309      * Creates a new {@code PluginDescriptor} instance using the specified requiredMavenVersion.
310      *
311      * @param requiredMavenVersion the new {@code String} to use
312      * @return a {@code PluginDescriptor} with the specified requiredMavenVersion
313      */
314     @Nonnull
315     public PluginDescriptor withRequiredMavenVersion(String requiredMavenVersion) {
316         return newBuilder(this, true).requiredMavenVersion(requiredMavenVersion).build();
317     }
318     /**
319      * Creates a new {@code PluginDescriptor} instance using the specified mojos.
320      *
321      * @param mojos the new {@code Collection<MojoDescriptor>} to use
322      * @return a {@code PluginDescriptor} with the specified mojos
323      */
324     @Nonnull
325     public PluginDescriptor withMojos(Collection<MojoDescriptor> mojos) {
326         return newBuilder(this, true).mojos(mojos).build();
327     }
328 
329     /**
330      * Creates a new {@code PluginDescriptor} instance.
331      * Equivalent to {@code newInstance(true)}.
332      * @see #newInstance(boolean)
333      *
334      * @return a new {@code PluginDescriptor}
335      */
336     @Nonnull
337     public static PluginDescriptor newInstance() {
338         return newInstance(true);
339     }
340 
341     /**
342      * Creates a new {@code PluginDescriptor} instance using default values or not.
343      * Equivalent to {@code newBuilder(withDefaults).build()}.
344      *
345      * @param withDefaults the boolean indicating whether default values should be used
346      * @return a new {@code PluginDescriptor}
347      */
348     @Nonnull
349     public static PluginDescriptor newInstance(boolean withDefaults) {
350         return newBuilder(withDefaults).build();
351     }
352 
353     /**
354      * Creates a new {@code PluginDescriptor} builder instance.
355      * Equivalent to {@code newBuilder(true)}.
356      * @see #newBuilder(boolean)
357      *
358      * @return a new {@code Builder}
359      */
360     @Nonnull
361     public static Builder newBuilder() {
362         return newBuilder(true);
363     }
364 
365     /**
366      * Creates a new {@code PluginDescriptor} builder instance using default values or not.
367      *
368      * @param withDefaults the boolean indicating whether default values should be used
369      * @return a new {@code Builder}
370      */
371     @Nonnull
372     public static Builder newBuilder(boolean withDefaults) {
373         return new Builder(withDefaults);
374     }
375 
376     /**
377      * Creates a new {@code PluginDescriptor} builder instance using the specified object as a basis.
378      * Equivalent to {@code newBuilder(from, false)}.
379      *
380      * @param from the {@code PluginDescriptor} instance to use as a basis
381      * @return a new {@code Builder}
382      */
383     @Nonnull
384     public static Builder newBuilder(PluginDescriptor from) {
385         return newBuilder(from, false);
386     }
387 
388     /**
389      * Creates a new {@code PluginDescriptor} builder instance using the specified object as a basis.
390      *
391      * @param from the {@code PluginDescriptor} instance to use as a basis
392      * @param forceCopy the boolean indicating if a copy should be forced
393      * @return a new {@code Builder}
394      */
395     @Nonnull
396     public static Builder newBuilder(PluginDescriptor from, boolean forceCopy) {
397         return new Builder(from, forceCopy);
398     }
399 
400     /**
401      * Builder class used to create PluginDescriptor instances.
402      * @see #with()
403      * @see #newBuilder()
404      */
405     @NotThreadSafe
406     public static class Builder
407     {
408         PluginDescriptor base;
409         String namespaceUri;
410         String modelEncoding;
411         String name;
412         String description;
413         String groupId;
414         String artifactId;
415         String version;
416         String goalPrefix;
417         Boolean isolatedRealm;
418         Boolean inheritedByDefault;
419         String requiredJavaVersion;
420         String requiredMavenVersion;
421         Collection<MojoDescriptor> mojos;
422 
423         protected Builder(boolean withDefaults) {
424             if (withDefaults) {
425                 this.isolatedRealm = false;
426                 this.inheritedByDefault = true;
427             }
428         }
429 
430         protected Builder(PluginDescriptor base, boolean forceCopy) {
431             this.namespaceUri = base.namespaceUri;
432             this.modelEncoding = base.modelEncoding;
433             if (forceCopy) {
434                 this.name = base.name;
435                 this.description = base.description;
436                 this.groupId = base.groupId;
437                 this.artifactId = base.artifactId;
438                 this.version = base.version;
439                 this.goalPrefix = base.goalPrefix;
440                 this.isolatedRealm = base.isolatedRealm;
441                 this.inheritedByDefault = base.inheritedByDefault;
442                 this.requiredJavaVersion = base.requiredJavaVersion;
443                 this.requiredMavenVersion = base.requiredMavenVersion;
444                 this.mojos = base.mojos;
445             } else {
446                 this.base = base;
447             }
448         }
449 
450         @Nonnull
451         public Builder namespaceUri(String namespaceUri) {
452             this.namespaceUri = namespaceUri;
453             return this;
454         }
455 
456         @Nonnull
457         public Builder modelEncoding(String modelEncoding) {
458             this.modelEncoding = modelEncoding;
459             return this;
460         }
461 
462         @Nonnull
463         public Builder name(String name) {
464             this.name = name;
465             return this;
466         }
467 
468         @Nonnull
469         public Builder description(String description) {
470             this.description = description;
471             return this;
472         }
473 
474         @Nonnull
475         public Builder groupId(String groupId) {
476             this.groupId = groupId;
477             return this;
478         }
479 
480         @Nonnull
481         public Builder artifactId(String artifactId) {
482             this.artifactId = artifactId;
483             return this;
484         }
485 
486         @Nonnull
487         public Builder version(String version) {
488             this.version = version;
489             return this;
490         }
491 
492         @Nonnull
493         public Builder goalPrefix(String goalPrefix) {
494             this.goalPrefix = goalPrefix;
495             return this;
496         }
497 
498         @Nonnull
499         public Builder isolatedRealm(boolean isolatedRealm) {
500             this.isolatedRealm = isolatedRealm;
501             return this;
502         }
503 
504         @Nonnull
505         public Builder inheritedByDefault(boolean inheritedByDefault) {
506             this.inheritedByDefault = inheritedByDefault;
507             return this;
508         }
509 
510         @Nonnull
511         public Builder requiredJavaVersion(String requiredJavaVersion) {
512             this.requiredJavaVersion = requiredJavaVersion;
513             return this;
514         }
515 
516         @Nonnull
517         public Builder requiredMavenVersion(String requiredMavenVersion) {
518             this.requiredMavenVersion = requiredMavenVersion;
519             return this;
520         }
521 
522         @Nonnull
523         public Builder mojos(Collection<MojoDescriptor> mojos) {
524             this.mojos = mojos;
525             return this;
526         }
527 
528 
529         @Nonnull
530         public PluginDescriptor build() {
531             // this method should not contain any logic other than creating (or reusing) an object in order to ease subclassing
532             if (base != null
533                     && (name == null || name == base.name)
534                     && (description == null || description == base.description)
535                     && (groupId == null || groupId == base.groupId)
536                     && (artifactId == null || artifactId == base.artifactId)
537                     && (version == null || version == base.version)
538                     && (goalPrefix == null || goalPrefix == base.goalPrefix)
539                     && (isolatedRealm == null || isolatedRealm == base.isolatedRealm)
540                     && (inheritedByDefault == null || inheritedByDefault == base.inheritedByDefault)
541                     && (requiredJavaVersion == null || requiredJavaVersion == base.requiredJavaVersion)
542                     && (requiredMavenVersion == null || requiredMavenVersion == base.requiredMavenVersion)
543                     && (mojos == null || mojos == base.mojos)
544             ) {
545                 return base;
546             }
547             return new PluginDescriptor(this);
548         }
549     }
550 
551 
552     public String getPluginLookupKey() {
553         return groupId + ":" + artifactId;
554     }
555 
556     public String getId() {
557         return groupId + ":" + artifactId + ":" + version;
558     }
559 
560           
561 }